Class: Sink::PageCursorID
- Inherits:
-
Object
- Object
- Sink::PageCursorID
- Defined in:
- lib/sink/page_cursor_id.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #auto_paging_each(&blk) ⇒ nil
-
#inspect ⇒ Object
String.
- #next_page ⇒ Sink::PageCursorID
- #next_page? ⇒ Boolean
Instance Attribute Details
#data ⇒ Array
6 7 8 |
# File 'lib/sink/page_cursor_id.rb', line 6 def data @data end |
Instance Method Details
#auto_paging_each(&blk) ⇒ nil
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sink/page_cursor_id.rb', line 33 def auto_paging_each(&blk) if !blk raise "A block must be given to #auto_paging_each" end page = self loop do page.data.each { |e| blk.call(e) } break if !page.next_page? page = page.next_page end end |
#inspect ⇒ Object
Returns String.
46 47 48 |
# File 'lib/sink/page_cursor_id.rb', line 46 def inspect "#<#{selfl.class}:0x#{object_id.to_s(16)} data=#{data.inspect}>" end |
#next_page ⇒ Sink::PageCursorID
25 26 27 28 29 30 |
# File 'lib/sink/page_cursor_id.rb', line 25 def next_page if !next_page? raise "No more pages available; please check #next_page? before calling #next_page" end client.request(Util.deep_merge(req, {query: {next_id: data.last.id}}), opts) end |
#next_page? ⇒ Boolean
20 21 22 |
# File 'lib/sink/page_cursor_id.rb', line 20 def next_page? !data.empty? end |