Class: Flying::Bot::Up
- Inherits:
-
Object
- Object
- Flying::Bot::Up
- Defined in:
- lib/flying/bots/up.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #assess(referer, *options) ⇒ Object
- #get_http_response_code(referer) ⇒ Object
-
#initialize ⇒ Up
constructor
A new instance of Up.
- #message_not_found ⇒ Object
- #message_server_error ⇒ Object
-
#message_unknown_error ⇒ Object
Messages.
- #message_unreachable ⇒ Object
- #set_error_message(referer, response_code, error_details = '') ⇒ Object
Constructor Details
#initialize ⇒ Up
Returns a new instance of Up.
8 9 10 |
# File 'lib/flying/bots/up.rb', line 8 def initialize @message = "Ok." end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/flying/bots/up.rb', line 6 def @message end |
Instance Method Details
#assess(referer, *options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/flying/bots/up.rb', line 12 def assess(referer, *) begin response_code = get_http_response_code(referer) rescue Flying.an_error_ocurred(true) (referer, false, $!) return false end return true if ["200", "302"].include? response_code Flying.an_error_ocurred(true) (referer, response_code.to_s) false end |
#get_http_response_code(referer) ⇒ Object
40 41 42 |
# File 'lib/flying/bots/up.rb', line 40 def get_http_response_code referer Net::HTTP.get_response(URI(referer)).code end |
#message_not_found ⇒ Object
53 54 55 |
# File 'lib/flying/bots/up.rb', line 53 def "The target was simply not found (404)." end |
#message_server_error ⇒ Object
57 58 59 |
# File 'lib/flying/bots/up.rb', line 57 def "We got a response saying there's a server error (501)" end |
#message_unknown_error ⇒ Object
Messages
45 46 47 |
# File 'lib/flying/bots/up.rb', line 45 def "An unknown error ocurred." end |
#message_unreachable ⇒ Object
49 50 51 |
# File 'lib/flying/bots/up.rb', line 49 def "It is unreachable (is the url correct?)." end |
#set_error_message(referer, response_code, error_details = '') ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/flying/bots/up.rb', line 26 def (referer, response_code, error_details = '') case response_code when false @message = when "404" @message = when "501" @message = else @message = + "(#{error_details})" end @message = referer + ": " + @message end |