Class: Shove::Http::Response
- Inherits:
-
Object
- Object
- Shove::Http::Response
- Defined in:
- lib/shove/http/response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#message ⇒ Object
Returns the value of attribute message.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#error? ⇒ Boolean
was there an error with the request?.
-
#initialize(status, message, error = false) ⇒ Response
constructor
A new instance of Response.
-
#parse ⇒ Object
parse a json response.
-
#to_hash ⇒ Object
alias parse.
Constructor Details
#initialize(status, message, error = false) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 |
# File 'lib/shove/http/response.rb', line 7 def initialize status, , error=false self.status = status.to_i self. = self.error = error end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
5 6 7 |
# File 'lib/shove/http/response.rb', line 5 def error @error end |
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/shove/http/response.rb', line 5 def @message end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/shove/http/response.rb', line 5 def status @status end |
Instance Method Details
#error? ⇒ Boolean
was there an error with the request?
14 15 16 |
# File 'lib/shove/http/response.rb', line 14 def error? error end |
#parse ⇒ Object
parse a json response
19 20 21 |
# File 'lib/shove/http/response.rb', line 19 def parse @parsed ||= Yajl::Parser.new(:symbolize_keys => true).parse() end |
#to_hash ⇒ Object
alias parse
24 25 26 |
# File 'lib/shove/http/response.rb', line 24 def to_hash parse end |