Class: Dillo::PaginatedCollection

Inherits:
Base
  • Object
show all
Includes:
Finders, Enumerable
Defined in:
lib/dillo.rb

Direct Known Subclasses

Views

Instance Attribute Summary

Attributes inherited from Base

#connection

Instance Method Summary collapse

Methods included from Finders

#[], #method_missing, #respond_to?

Methods inherited from Base

#body, #inspect, #json, #prepare_request, root

Constructor Details

#initializePaginatedCollection

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_pageObject



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

#page(number) ⇒ Object



101
102
103
# File 'lib/dillo.rb', line 101

def page(number)
  @pages[number] ||= Page.new(self, number)
end