Class: Dillo::PaginatedCollection
- Includes:
- Finders, Enumerable
- Defined in:
- lib/dillo.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #each_page ⇒ Object
-
#initialize ⇒ PaginatedCollection
constructor
A new instance of PaginatedCollection.
- #page(number) ⇒ Object
Methods included from Finders
#[], #method_missing, #respond_to?
Methods inherited from Base
#body, #inspect, #json, #prepare_request, root
Constructor Details
#initialize ⇒ PaginatedCollection
Returns a new instance of PaginatedCollection.
97 98 99 |
# File 'lib/dillo.rb', line 97 def initialize @pages ||= {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dillo::Finders
Instance Method Details
#each(&block) ⇒ Object
115 116 117 118 119 |
# File 'lib/dillo.rb', line 115 def each(&block) each_page do |page| page.each(&block) end end |
#each_page ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/dillo.rb', line 105 def each_page number = 1 loop do page = self.page(number) break if page.count.zero? yield page number += 1 end end |