Class: Twitter::OAuth

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/twitter/oauth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctoken, csecret) ⇒ OAuth

Returns a new instance of OAuth.



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

def initialize(ctoken, csecret)
  @ctoken, @csecret = ctoken, csecret
end

Instance Attribute Details

#csecretObject (readonly)

Returns the value of attribute csecret.



6
7
8
# File 'lib/twitter/oauth.rb', line 6

def csecret
  @csecret
end

#ctokenObject (readonly)

Returns the value of attribute ctoken.



6
7
8
# File 'lib/twitter/oauth.rb', line 6

def ctoken
  @ctoken
end

Instance Method Details

#access_tokenObject



26
27
28
# File 'lib/twitter/oauth.rb', line 26

def access_token
  @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret)
end

#authorize_from_access(atoken, asecret) ⇒ Object



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

def authorize_from_access(atoken, asecret)
  @atoken, @asecret = atoken, asecret
end

#authorize_from_request(rtoken, rsecret) ⇒ Object



20
21
22
23
24
# File 'lib/twitter/oauth.rb', line 20

def authorize_from_request(rtoken, rsecret)
  request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret)
  access_token = request_token.get_access_token
  @atoken, @asecret = access_token.token, access_token.secret
end

#consumerObject



12
13
14
# File 'lib/twitter/oauth.rb', line 12

def consumer
  @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => 'http://twitter.com'})
end

#request_tokenObject



16
17
18
# File 'lib/twitter/oauth.rb', line 16

def request_token
  @request_token ||= consumer.get_request_token
end