Class: HTTParty::Response
- Inherits:
- BasicObject
- Defined in:
- lib/httparty/response.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Headers
Constant Summary collapse
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #class ⇒ Object
- #code ⇒ Object
-
#initialize(response, parsed_response) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
Constructor Details
#initialize(response, parsed_response) ⇒ Response
Returns a new instance of Response.
38 39 40 41 42 43 |
# File 'lib/httparty/response.rb', line 38 def initialize(response, parsed_response) @response = response @body = response.body @parsed_response = parsed_response @headers = Headers.new(response.to_hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
69 70 71 72 73 74 75 76 77 |
# File 'lib/httparty/response.rb', line 69 def method_missing(name, *args, &block) if parsed_response.respond_to?(name) parsed_response.send(name, *args, &block) elsif response.respond_to?(name) response.send(name, *args, &block) else super end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
36 37 38 |
# File 'lib/httparty/response.rb', line 36 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
36 37 38 |
# File 'lib/httparty/response.rb', line 36 def headers @headers end |
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
36 37 38 |
# File 'lib/httparty/response.rb', line 36 def parsed_response @parsed_response end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
36 37 38 |
# File 'lib/httparty/response.rb', line 36 def response @response end |
Class Method Details
.underscore(string) ⇒ Object
32 33 34 |
# File 'lib/httparty/response.rb', line 32 def self.underscore(string) string.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase end |
Instance Method Details
#class ⇒ Object
45 46 47 |
# File 'lib/httparty/response.rb', line 45 def class Response end |
#code ⇒ Object
49 50 51 |
# File 'lib/httparty/response.rb', line 49 def code response.code.to_i end |
#inspect ⇒ Object
53 54 55 56 |
# File 'lib/httparty/response.rb', line 53 def inspect inspect_id = "%x" % (object_id * 2) %(#<#{self.class}:0x#{inspect_id} @parsed_response=#{parsed_response.inspect}, @response=#{response.inspect}, @headers=#{headers.inspect}>) end |