Class: HttpFind::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/http_find/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/http_find/response.rb', line 6

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/http_find/response.rb', line 5

def code
  @code
end