Class: BubbleWrap::HTTP::Response
- Inherits:
-
Object
- Object
- BubbleWrap::HTTP::Response
- Defined in:
- motion/http.rb
Overview
Response class wrapping the results of a Query’s response
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
- #to_s ⇒ Object (also: #description)
- #update(values) ⇒ Object
Constructor Details
#initialize(values = {}) ⇒ Response
Returns a new instance of Response.
62 63 64 |
# File 'motion/http.rb', line 62 def initialize(values={}) self.update(values) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
57 58 59 |
# File 'motion/http.rb', line 57 def body @body end |
#error_message ⇒ Object
Returns the value of attribute error_message.
59 60 61 |
# File 'motion/http.rb', line 59 def @error_message end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
58 59 60 |
# File 'motion/http.rb', line 58 def headers @headers end |
#status_code ⇒ Object
Returns the value of attribute status_code.
59 60 61 |
# File 'motion/http.rb', line 59 def status_code @status_code end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
60 61 62 |
# File 'motion/http.rb', line 60 def url @url end |
Instance Method Details
#ok? ⇒ Boolean
72 73 74 |
# File 'motion/http.rb', line 72 def ok? status_code.to_s =~ /20\d/ ? true : false end |
#to_s ⇒ Object Also known as: description
76 77 78 |
# File 'motion/http.rb', line 76 def to_s "#<#{self.class}:#{self.object_id} - url: #{self.url}, body: #{self.body}, headers: #{self.headers}, status code: #{self.status_code}, error message: #{self.} >" end |
#update(values) ⇒ Object
66 67 68 69 70 |
# File 'motion/http.rb', line 66 def update(values) values.each do |k,v| self.instance_variable_set("@#{k}", v) end end |