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
8 9 10 11 12 |
# File 'lib/gh/pagination.rb', line 8 def initialize(page, url, gh) @page = page @next_url = url @gh = gh end |
Instance Method Details
#[](value) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/gh/pagination.rb', line 25 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
14 15 16 17 18 19 |
# File 'lib/gh/pagination.rb', line 14 def each(&block) return enum_for(:each) unless block @page.each(&block) next_page.each(&block) end |
#headers ⇒ Object
36 37 38 |
# File 'lib/gh/pagination.rb', line 36 def headers @page.headers end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/gh/pagination.rb', line 21 def inspect "[#{first.inspect}, ...]" end |
#to_ary ⇒ Object
32 33 34 |
# File 'lib/gh/pagination.rb', line 32 def to_ary to_a # replace with better implementation (use in_parallel) end |