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

Parameters:

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

Yields:

  • (_self)

Yield Parameters:



15
16
17
18
19
20
# File 'lib/twitter/client.rb', line 15

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

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



8
9
10
# File 'lib/twitter/client.rb', line 8

def access_token
  @access_token
end

#access_token_secretObject

Returns the value of attribute access_token_secret.



8
9
10
# File 'lib/twitter/client.rb', line 8

def access_token_secret
  @access_token_secret
end

#consumer_keyObject

Returns the value of attribute consumer_key.



8
9
10
# File 'lib/twitter/client.rb', line 8

def consumer_key
  @consumer_key
end

#consumer_secretObject

Returns the value of attribute consumer_secret.



8
9
10
# File 'lib/twitter/client.rb', line 8

def consumer_secret
  @consumer_secret
end

#dev_environmentObject

Returns the value of attribute dev_environment.



8
9
10
# File 'lib/twitter/client.rb', line 8

def dev_environment
  @dev_environment
end

#proxyObject

Returns the value of attribute proxy.



8
9
10
# File 'lib/twitter/client.rb', line 8

def proxy
  @proxy
end

#timeoutsObject

Returns the value of attribute timeouts.



8
9
10
# File 'lib/twitter/client.rb', line 8

def timeouts
  @timeouts
end

#user_agentString

Returns:

  • (String)


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

def user_agent
  @user_agent ||= "TwitterRubyGem/#{Twitter::Version}"
end

Instance Method Details

#credentialsHash

Returns:

  • (Hash)


33
34
35
36
37
38
39
40
# File 'lib/twitter/client.rb', line 33

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

#credentials?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/twitter/client.rb', line 43

def credentials?
  credentials.values.none? { |v| blank_string?(v) }
end

#user_token?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/twitter/client.rb', line 23

def user_token?
  !(blank_string?(access_token) || blank_string?(access_token_secret))
end