Class: Slack::Pager
- Inherits:
-
Object
- Object
- Slack::Pager
- Defined in:
- lib/laziness/pager.rb
Instance Attribute Summary collapse
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(page) ⇒ Pager
constructor
A new instance of Pager.
- #next(cursor) ⇒ Object
- #to_h ⇒ Object
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
#cursor ⇒ Object
Returns the value of attribute cursor.
5 6 7 |
# File 'lib/laziness/pager.rb', line 5 def cursor @cursor end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
5 6 7 |
# File 'lib/laziness/pager.rb', line 5 def limit @limit end |
#page ⇒ Object (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
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_h ⇒ Object
16 17 18 |
# File 'lib/laziness/pager.rb', line 16 def to_h { cursor: cursor, limit: limit } end |