Class: Sink::PageCursorFromHeaders
- Inherits:
-
Object
- Object
- Sink::PageCursorFromHeaders
- Defined in:
- lib/sink/page_cursor_from_headers.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #auto_paging_each(&blk) ⇒ nil
-
#inspect ⇒ Object
String.
- #next_page ⇒ Sink::PageCursorFromHeaders
- #next_page? ⇒ Boolean
Instance Attribute Details
#data ⇒ Array
6 7 8 |
# File 'lib/sink/page_cursor_from_headers.rb', line 6 def data @data end |
#my_cursor ⇒ String
9 10 11 |
# File 'lib/sink/page_cursor_from_headers.rb', line 9 def my_cursor @my_cursor end |
Instance Method Details
#auto_paging_each(&blk) ⇒ nil
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sink/page_cursor_from_headers.rb', line 37 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.
50 51 52 |
# File 'lib/sink/page_cursor_from_headers.rb', line 50 def inspect "#<#{selfl.class}:0x#{object_id.to_s(16)} data=#{data.inspect} my_cursor=#{my_cursor.inspect}>" end |
#next_page ⇒ Sink::PageCursorFromHeaders
29 30 31 32 33 34 |
# File 'lib/sink/page_cursor_from_headers.rb', line 29 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: {cursor: my_cursor}}), opts) end |
#next_page? ⇒ Boolean
24 25 26 |
# File 'lib/sink/page_cursor_from_headers.rb', line 24 def next_page? !my_cursor.nil? end |