Class: GH::Pagination::Paginated
- Inherits:
-
Object
- Object
- GH::Pagination::Paginated
- Includes:
- Enumerable
- Defined in:
- lib/gh/pagination.rb
Instance Method Summary collapse
- #[](value) ⇒ Object
- #each(&block) ⇒ Object
- #headers ⇒ Object
-
#initialize(page, url, gh) ⇒ Paginated
constructor
A new instance of Paginated.
- #inspect ⇒ Object
- #to_ary ⇒ Object
Constructor Details
#initialize(page, url, gh) ⇒ Paginated
Returns a new instance of Paginated.
6 7 8 |
# File 'lib/gh/pagination.rb', line 6 def initialize(page, url, gh) @page, @next_url, @gh = page, url, gh end |
Instance Method Details
#[](value) ⇒ Object
20 21 22 23 24 |
# File 'lib/gh/pagination.rb', line 20 def [](value) raise TypeError, "index has to be an Integer, got #{value.class}" unless value.is_a? Integer return @page[value] if value < @page.size next_page[value - @page.size] end |
#each(&block) ⇒ Object
10 11 12 13 14 |
# File 'lib/gh/pagination.rb', line 10 def each(&block) return enum_for(:each) unless block @page.each(&block) next_page.each(&block) end |
#headers ⇒ Object
30 31 32 |
# File 'lib/gh/pagination.rb', line 30 def headers @page.headers end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/gh/pagination.rb', line 16 def inspect "[#{first.inspect}, ...]" end |
#to_ary ⇒ Object
26 27 28 |
# File 'lib/gh/pagination.rb', line 26 def to_ary to_a # replace with better implementation (use in_parallel) end |