Class: Myun2::TwitterShell::Authorize

Inherits:
Object
  • Object
show all
Defined in:
lib/myun2/twitter_shell/authorize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuthorize

Returns a new instance of Authorize.



8
9
10
11
12
13
14
15
16
17
# File 'lib/myun2/twitter_shell/authorize.rb', line 8

def initialize
  puts "* Requesting authorization URL ..."
  auth_url = request_authorize_url
  puts "  " + auth_url
  puts "* Please access to above URL in your browser."
  puts "  And permit application 'Myun2 Twitter Shell (Twsh)."
  puts "  And enter shown PIN code to under."
  print "PIN> "
  read_pin && authorize
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



6
7
8
# File 'lib/myun2/twitter_shell/authorize.rb', line 6

def access_token
  @access_token
end

#pinObject (readonly)

Returns the value of attribute pin.



6
7
8
# File 'lib/myun2/twitter_shell/authorize.rb', line 6

def pin
  @pin
end

Instance Method Details

#authorizeObject



30
31
32
# File 'lib/myun2/twitter_shell/authorize.rb', line 30

def authorize
  @access_token = @auth.authorize(@pin)
end

#read_pinObject



26
27
28
# File 'lib/myun2/twitter_shell/authorize.rb', line 26

def read_pin
  @pin = gets.chomp
end

#request_authorize_urlObject



19
20
21
22
23
24
# File 'lib/myun2/twitter_shell/authorize.rb', line 19

def request_authorize_url
  @auth = Myun2::Twitter::Authenticate.new(
    consumer_key: ConsumerKey::KEY,
    consumer_secret: ConsumerKey::SECRET)
  @auth.request_authorize_url
end