Class: Sink::PageCursorWithReverse

Inherits:
Object
  • Object
show all
Defined in:
lib/sink/page_cursor_with_reverse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataArray

Returns:

  • (Array)


6
7
8
# File 'lib/sink/page_cursor_with_reverse.rb', line 6

def data
  @data
end

#first_idString

Returns:

  • (String)


9
10
11
# File 'lib/sink/page_cursor_with_reverse.rb', line 9

def first_id
  @first_id
end

#last_idString

Returns:

  • (String)


12
13
14
# File 'lib/sink/page_cursor_with_reverse.rb', line 12

def last_id
  @last_id
end

Instance Method Details

#auto_paging_each(&blk) ⇒ nil

Returns:

  • (nil)


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/sink/page_cursor_with_reverse.rb', line 41

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

#inspectObject

Returns String.

Returns:

  • String



54
55
56
# File 'lib/sink/page_cursor_with_reverse.rb', line 54

def inspect
  "#<#{selfl.class}:0x#{object_id.to_s(16)} data=#{data.inspect} first_id=#{first_id.inspect} last_id=#{last_id.inspect}>"
end

#next_pageSink::PageCursorWithReverse



33
34
35
36
37
38
# File 'lib/sink/page_cursor_with_reverse.rb', line 33

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: {after_id: last_id}}), opts)
end

#next_page?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/sink/page_cursor_with_reverse.rb', line 28

def next_page?
  !last_id.nil?
end