Class: Robin::Actions::Authenticate

Inherits:
Object
  • Object
show all
Defined in:
lib/robin/actions/authenticate.rb

Instance Method Summary collapse

Instance Method Details

#execute(client, output, input) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/robin/actions/authenticate.rb', line 5

def execute(client, output, input)
  output.print instructions(PinAuthenticator.authorize_url)
  pin = input.gets.chomp
  if PinAuthenticator.authenticate(pin)
    output.puts success
  else
    output.puts failed
  end
end

#failedObject



34
35
36
# File 'lib/robin/actions/authenticate.rb', line 34

def failed
  "Pin was incorrect"
end

#instructions(url) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/robin/actions/authenticate.rb', line 15

def instructions(url)
  instructions = <<EOF 
In order to use Robin you need to authenticate with your Twitter account.
To do this, first, point your browser to the following URL:

#{url}

Log in if required. 
You must now authorize the app and type the given PIN.

PIN >> 
EOF
  instructions.chomp
end

#successObject



30
31
32
# File 'lib/robin/actions/authenticate.rb', line 30

def success
  "Great. You can now use Robin."
end