Class: Flute::Response
- Inherits:
-
Object
- Object
- Flute::Response
- Defined in:
- lib/flute/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #parse_html ⇒ Object
- #parse_json ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
4 5 6 7 |
# File 'lib/flute/response.rb', line 4 def initialize(response) @status = response.code @body = response.body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/flute/response.rb', line 3 def body @body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/flute/response.rb', line 3 def status @status end |
Instance Method Details
#parse_html ⇒ Object
13 14 15 |
# File 'lib/flute/response.rb', line 13 def parse_html @parse_html ||= Document.parse(@body) end |
#parse_json ⇒ Object
17 18 19 |
# File 'lib/flute/response.rb', line 17 def parse_json @parse_json ||= JSON.parse(@body).symbolize_keys end |
#success? ⇒ Boolean
9 10 11 |
# File 'lib/flute/response.rb', line 9 def success? 200 <= @status && @status < 300 end |