Class: HTTPalooza::Players::UserBrowserPlayer

Inherits:
Base
  • Object
show all
Defined in:
lib/httpalooza/players/user_browser.rb

Instance Attribute Summary

Attributes inherited from Base

#request

Instance Method Summary collapse

Methods inherited from Base

execute!, #initialize, introducing!, #name

Constructor Details

This class inherits a constructor from HTTPalooza::Players::Base

Instance Method Details

#responseObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/httpalooza/players/user_browser.rb', line 6

def response
  STDOUT.puts "Please open your web browser and go to the following URL: #{request.url}"

  prompt = "Do you think the page loaded properly? (y/n/maybe): "
  STDOUT.print(prompt)
  while answer = STDIN.gets.chomp
    case answer
    when /y/i
      code = 200
      break
    when /n/i
      code = 404
      break
    else
      STDOUT.print(prompt)
    end
  end

  STDOUT.puts "View the source of the page, then copy and paste the whole source here (^D when finished)."
  body = STDIN.read
  STDOUT.puts "\n\n"

  Response.new(code, body)
end