Class: Rebay::Response
- Inherits:
-
Object
- Object
- Rebay::Response
- Defined in:
- lib/rebay/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #each ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(json_response) ⇒ Response
constructor
A new instance of Response.
- #size ⇒ Object
- #success? ⇒ Boolean
- #trim(key) ⇒ Object
Constructor Details
#initialize(json_response) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/rebay/response.rb', line 6 def initialize(json_response) @response = transform_json_response(json_response) end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/rebay/response.rb', line 3 def response @response end |
#results ⇒ Object
Returns the value of attribute results.
4 5 6 |
# File 'lib/rebay/response.rb', line 4 def results @results end |
Instance Method Details
#each ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/rebay/response.rb', line 24 def each unless @results.nil? if @results.class == Array @results.each { |r| yield r } else yield @results end end end |
#failure? ⇒ Boolean
14 15 16 |
# File 'lib/rebay/response.rb', line 14 def failure? @response["Ack"] == 'Failure' || @response['ack'] == 'Failure' end |
#size ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/rebay/response.rb', line 34 def size if @results.nil? return 0 elsif @results.class == Array return @results.size else return 1 end end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/rebay/response.rb', line 10 def success? @response["Ack"] == 'Success' || @response['ack'] == 'Success' end |
#trim(key) ⇒ Object
18 19 20 21 22 |
# File 'lib/rebay/response.rb', line 18 def trim(key) if @response.has_key?(key.to_s) @response = @response[key.to_s] end end |