Class: Windy::PaginatedCollection

Inherits:
Base
  • Object
show all
Includes:
Enumerable, Finders
Defined in:
lib/windy.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.



84
85
86
# File 'lib/windy.rb', line 84

def initialize
  @pages ||= {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Windy::Finders

Instance Method Details

#each(&block) ⇒ Object



102
103
104
105
106
# File 'lib/windy.rb', line 102

def each(&block)
  each_page do |page|
    page.each(&block)
  end
end

#each_pageObject



92
93
94
95
96
97
98
99
100
# File 'lib/windy.rb', line 92

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



88
89
90
# File 'lib/windy.rb', line 88

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