Class: BestbuyApi::Response
- Inherits:
-
Object
- Object
- BestbuyApi::Response
- Defined in:
- lib/bestbuy_api/response.rb
Constant Summary collapse
- PAGE_VARS =
%w[totalPages total currentPage].freeze
Instance Method Summary collapse
-
#initialize(result, path) ⇒ Response
constructor
A new instance of Response.
- #items ⇒ Object
- #pagination ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(result, path) ⇒ Response
Returns a new instance of Response.
5 6 7 8 |
# File 'lib/bestbuy_api/response.rb', line 5 def initialize(result, path) @result = result @path = path end |
Instance Method Details
#items ⇒ Object
10 11 12 |
# File 'lib/bestbuy_api/response.rb', line 10 def items @result[@path] if @result.key?(@path) end |
#pagination ⇒ Object
14 15 16 |
# File 'lib/bestbuy_api/response.rb', line 14 def pagination @result.select { |key| PAGE_VARS.include?(key) } end |
#url ⇒ Object
18 19 20 |
# File 'lib/bestbuy_api/response.rb', line 18 def url @result.request.last_uri.to_s end |