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

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

Initializes a new Client object

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|
    instance_variable_set("@#{key}", value)
  end
  yield(self) if block_given?
  validate_credential_type!
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token



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

def access_token
  @access_token
end

#access_token_secretObject

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

#consumer_keyObject

Returns the value of attribute consumer_key



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

def consumer_key
  @consumer_key
end

#consumer_secretObject

Returns the value of attribute consumer_secret



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

def consumer_secret
  @consumer_secret
end

#proxyObject

Returns the value of attribute proxy



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

def proxy
  @proxy
end

#user_agentString



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

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

Instance Method Details

#credentialsHash



40
41
42
43
44
45
46
47
48
# 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,
    :ignore_extra_keys => true,
  }
end

#credentials?Boolean



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

def credentials?
  credentials.values.all?
end

#user_token?Boolean



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

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