Class: RakutenWebService::Response
- Inherits:
-
Object
- Object
- RakutenWebService::Response
- Includes:
- Enumerable
- Defined in:
- lib/rakuten_web_service/response.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each ⇒ Object
- #has_next_page? ⇒ Boolean
-
#initialize(resource_class, json) ⇒ Response
constructor
A new instance of Response.
- #last_page? ⇒ Boolean
- #resources ⇒ Object
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 |
#each ⇒ Object
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
31 32 33 |
# File 'lib/rakuten_web_service/response.rb', line 31 def has_next_page? page && (not last_page?) end |
#last_page? ⇒ Boolean
35 36 37 |
# File 'lib/rakuten_web_service/response.rb', line 35 def last_page? page >= page_count end |
#resources ⇒ Object
27 28 29 |
# File 'lib/rakuten_web_service/response.rb', line 27 def resources @resources ||= @resource_class.parse_response(@json) end |