class

Tourmaline::PaginatedKeyboard

Inherits Reference < Object

Convenience class for creating an InlineKeyboard with built in pagination. It is designed to be customizable so as not to get in your way.

Constructors

new(results = [] of String, per_page = 10, &block : self -> )

Creates a new PaginatedKeyboard, yielding the newly created keyboard to the block

Arguments

  • results - the initial set of results
  • per_page - the number of results to show on each page
  • header - text to be displayed above the results
  • footer - text to be displayed below the results
  • prefix - a string to be added to the beginning of each item
  • back_text - text to use for the back button
  • next_text - text to use for the next button
  • id - an id to be used both as the group name, and the prefix for the callback query data

Formatting

The params header, footer, and prefix are formatted prior to being injected into the message.

  • {page} - will be replaced with the current page number, starting at 1
  • {page count} - will be replaced with the total number of pages
  • {index} - for prefix only, gets replaced with the index of the current item, starting at 1
Source

Instance methods

<<(*args, **options)
Source
<<(*args, **options, &)
Source
back_button_procs
Source
back_button_procs=(back_button_procs : Array(Proc(PaginatedKeyboard, Nil)))
Source
current_page

Returns the content for the current page

Source
delete(*args, **options)
Source
delete(*args, **options, &)
Source
each(*args, **options)
Source
each(*args, **options, &)
Source
event_handler
Source
header
Source
header=(header : String | Nil)
Source
index(*args, **options)
Source
index(*args, **options, &)
Source
keyboard
Source
next_button_procs
Source
next_button_procs=(next_button_procs : Array(Proc(PaginatedKeyboard, Nil)))
Source
on_back

Adds a back button callback handler

Source
on_next

Adds a next button callback handler

Source
pages

Returns each page, with it's items

Source
per_page
Source
per_page=(per_page : Int32)
Source
prefix
Source
prefix=(prefix : String | Nil)
Source
push(*args, **options)
Source
push(*args, **options, &)
Source
results
Source
results=(results : Array(String))
Source