Class: Slack::Pager

Inherits:
Object
  • Object
show all
Defined in:
lib/laziness/pager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Pager

Returns a new instance of Pager.



7
8
9
10
# File 'lib/laziness/pager.rb', line 7

def initialize(page)
  @page = page.dup
  @limit = @page[:limit] unless empty?
end

Instance Attribute Details

#cursorObject

Returns the value of attribute cursor.



5
6
7
# File 'lib/laziness/pager.rb', line 5

def cursor
  @cursor
end

#limitObject (readonly)

Returns the value of attribute limit.



5
6
7
# File 'lib/laziness/pager.rb', line 5

def limit
  @limit
end

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'lib/laziness/pager.rb', line 5

def page
  @page
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/laziness/pager.rb', line 12

def empty?
  page.nil? || page.empty?
end

#next(cursor) ⇒ Object



20
21
22
23
24
# File 'lib/laziness/pager.rb', line 20

def next(cursor)
  self.class.new(page).tap do |pager|
    pager.cursor = cursor
  end
end

#to_hObject



16
17
18
# File 'lib/laziness/pager.rb', line 16

def to_h
  { cursor: cursor, limit: limit }
end