Class: HTTParty::Response
- Defined in:
- lib/motion-bundler/mocks/httparty.rb
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(response, data, options = {}) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
- #parsed_response ⇒ Object
Constructor Details
#initialize(response, data, options = {}) ⇒ Response
Returns a new instance of Response.
114 115 116 117 |
# File 'lib/motion-bundler/mocks/httparty.rb', line 114 def initialize(response, data, = {}) @cached_response = NSCachedURLResponse.alloc.initWithResponse response, data: data @options = end |
Instance Method Details
#code ⇒ Object
130 131 132 |
# File 'lib/motion-bundler/mocks/httparty.rb', line 130 def code @cached_response.response.statusCode end |
#ok? ⇒ Boolean
134 135 136 |
# File 'lib/motion-bundler/mocks/httparty.rb', line 134 def ok? code.to_s.match /^20\d$/ end |
#parsed_response ⇒ Object
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/motion-bundler/mocks/httparty.rb', line 119 def parsed_response @parsed_response ||= begin case @options[:format] when :json NSJSONSerialization.JSONObjectWithData @cached_response.data, options: NSJSONReadingMutableContainers, error: nil else NSString.alloc.initWithData @cached_response.data, encoding: NSUTF8StringEncoding end end end |