Class: RakutenWebService::Response

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rakuten_web_service/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource_class, json) ⇒ Response

Returns a new instance of Response.



5
6
7
8
# File 'lib/rakuten_web_service/response.rb', line 5

def initialize(resource_class, json)
  @resource_class = resource_class
  @json = json.dup
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/rakuten_web_service/response.rb', line 10

def [](key)
  @json[key]
end

#eachObject



14
15
16
17
18
# File 'lib/rakuten_web_service/response.rb', line 14

def each
  resources.each do |resource|
    yield resource
  end
end

#has_next_page?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rakuten_web_service/response.rb', line 31

def has_next_page?
  page && (not last_page?)
end

#last_page?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rakuten_web_service/response.rb', line 35

def last_page?
  page >= page_count
end

#resourcesObject



27
28
29
# File 'lib/rakuten_web_service/response.rb', line 27

def resources
  @resources ||= @resource_class.parse_response(@json)
end