Class: Twitter::Client

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/twitter/client.rb

Direct Known Subclasses

REST::Client, Streaming::Client

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Utils

flat_pmap, pmap

Constructor Details

- (Twitter::Client) initialize(options = {}) {|_self| ... }

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})

Yields:

  • (_self)

Yield Parameters:



21
22
23
24
25
26
27
# File 'lib/twitter/client.rb', line 21

def initialize(options = {})
  options.each do |key, value|
    send(:#{key}=", value)
  end
  yield(self) if block_given?
  validate_credential_type!
end

Instance Attribute Details

- (Object) access_token

Returns the value of attribute access_token



10
11
12
# File 'lib/twitter/client.rb', line 10

def access_token
  @access_token
end

- (Object) access_token_secret

Returns the value of attribute access_token_secret



10
11
12
# File 'lib/twitter/client.rb', line 10

def access_token_secret
  @access_token_secret
end

- (Object) consumer_key

Returns the value of attribute consumer_key



10
11
12
# File 'lib/twitter/client.rb', line 10

def consumer_key
  @consumer_key
end

- (Object) consumer_secret

Returns the value of attribute consumer_secret



10
11
12
# File 'lib/twitter/client.rb', line 10

def consumer_secret
  @consumer_secret
end

- (Object) proxy

Returns the value of attribute proxy



10
11
12
# File 'lib/twitter/client.rb', line 10

def proxy
  @proxy
end

- (String) user_agent

Returns:

  • (String)


35
36
37
# File 'lib/twitter/client.rb', line 35

def user_agent
  @user_agent ||= "Twitter Ruby Gem #{Twitter::Version}"
end

Instance Method Details

- (Hash) credentials

Returns:

  • (Hash)


40
41
42
43
44
45
46
47
# File 'lib/twitter/client.rb', line 40

def credentials
  {
    :consumer_key    => consumer_key,
    :consumer_secret => consumer_secret,
    :token           => access_token,
    :token_secret    => access_token_secret,
  }
end

- (Boolean) credentials?

Returns:

  • (Boolean)


50
51
52
# File 'lib/twitter/client.rb', line 50

def credentials?
  credentials.values.all?
end

- (Boolean) user_token?

Returns:

  • (Boolean)


30
31
32
# File 'lib/twitter/client.rb', line 30

def user_token?
  !!(access_token && access_token_secret)
end