Class: ApiBucket::Rakuten::Response

Inherits:
Base::Response show all
Defined in:
lib/api_bucket/rakuten/response.rb

Instance Attribute Summary

Attributes inherited from Base::Response

#count, #page

Instance Method Summary collapse

Methods inherited from Base::Response

#doc, #dump

Constructor Details

#initialize(xml) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/api_bucket/rakuten/response.rb', line 6

def initialize(xml)
  @doc = xml
end

Instance Method Details

#first_itemObject



15
16
17
# File 'lib/api_bucket/rakuten/response.rb', line 15

def first_item
  @items[0]
end

#item_pageObject



19
20
21
22
# File 'lib/api_bucket/rakuten/response.rb', line 19

def item_page
  @item_page = 0 if @doc.nil?
  @item_page ||= @doc[:page].to_i
end

#itemsObject



10
11
12
13
# File 'lib/api_bucket/rakuten/response.rb', line 10

def items
  return [] if @doc.nil?
  @items ||= @doc["Items"].map {|item| ApiBucket::Rakuten::Item.new(item['Item']) }
end

#total_pagesObject



29
30
31
32
# File 'lib/api_bucket/rakuten/response.rb', line 29

def total_pages
  @total_pages = 0 if @doc.nil?
  @total_pages ||= @doc[:pageCount].to_i
end

#total_resultsObject



24
25
26
27
# File 'lib/api_bucket/rakuten/response.rb', line 24

def total_results
  @total_results = 0 if @doc.nil?
  @total_results ||= @doc[:count].to_i
end