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, pmap_with_index

Constructor Details

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

Initializes a new Client object

Parameters:

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

Yields:

  • (_self)

Yield Parameters:



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

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

Instance Method Details

- (Hash) credentials

Returns:

  • (Hash)


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

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

- (Boolean) credentials?

Returns:

  • (Boolean)


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

def credentials?
  credentials.values.all?
end

- (String) user_agent

Returns:

  • (String)


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

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

- (Boolean) user_token?

Returns:

  • (Boolean)


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

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