class Rebay2::Response
Attributes
response[RW]
results[RW]
Public Class Methods
new(json_response)
click to toggle source
# File lib/rebay2/response.rb, line 6 def initialize(json_response) @response = transform_json_response(json_response) end
Public Instance Methods
each() { |r| ... }
click to toggle source
# File lib/rebay2/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?()
click to toggle source
# File lib/rebay2/response.rb, line 14 def failure? @response["Ack"] == 'Failure' || @response['ack'] == 'Failure' end
size()
click to toggle source
# File lib/rebay2/response.rb, line 34 def size if @results.nil? return 0 elsif @results.class == Array return @results.size else return 1 end end
success?()
click to toggle source
# File lib/rebay2/response.rb, line 10 def success? @response["Ack"] == 'Success' || @response['ack'] == 'Success' end
trim(key)
click to toggle source
# File lib/rebay2/response.rb, line 18 def trim(key) if @response.has_key?(key.to_s) @response = @response[key.to_s] end end
Protected Instance Methods
transform_json_response(response)
click to toggle source
# File lib/rebay2/response.rb, line 45 def transform_json_response(response) if response.class == Hash r = Hash.new response.keys.each do |k| r[k] = transform_json_response(response[k]) end return r elsif response.class == Array if response.size == 1 return transform_json_response(response[0]) else r = Array.new response.each do |a| r.push(transform_json_response(a)) end return r end else return response end end