Class: HttpFind::Response
- Inherits:
-
Object
- Object
- HttpFind::Response
- Defined in:
- lib/http_find/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(uri) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(uri) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 |
# File 'lib/http_find/response.rb', line 8 def initialize(uri) furi = uri.start_with?("http") ? uri : "http://#{uri}" party = HTTParty.get(furi) @code = party.response.code.to_i @body = @code == 200 ? party.response.body : nil end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/http_find/response.rb', line 6 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/http_find/response.rb', line 5 def code @code end |