Skip to content

class Tourmaline::PaginatedKeyboard
inherits Reference #

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(client : Tourmaline::Client, results = [] of String, per_page = 10, header = nil, footer = nil, prefix = nil, back_text = "Back", next_text = "Next", id = Helpers.random_string(8)) #

Creates a new PaginatedKeyboard

View source

.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

View source

Methods#

#<<(*args, **options) #

View source

#back_button_procs : Array(Proc(PaginatedKeyboard, Nil)) #

View source

#back_button_procs=(back_button_procs : Array(Proc(PaginatedKeyboard, Nil))) #

View source

#current_page #

Returns the content for the current page

View source

#delete #

View source

#delete(*args, **options) #

View source

#each #

View source

#each(*args, **options) #

View source

#footer : String? #

View source

#footer=(footer : String?) #

View source

#header : String? #

View source

#header=(header : String?) #

View source

#index(*args, **options) #

View source

#index #

View source

#next_button_procs : Array(Proc(PaginatedKeyboard, Nil)) #

View source

#next_button_procs=(next_button_procs : Array(Proc(PaginatedKeyboard, Nil))) #

View source

#on_back(&block : self -> ) #

Adds a back button callback handler

View source

#on_next(&block : self -> ) #

Adds a next button callback handler

View source

#pages #

Returns each page, with it's items

View source

#per_page : Int32 #

View source

#per_page=(per_page : Int32) #

View source

#prefix : String? #

View source

#prefix=(prefix : String?) #

View source

#push(*args, **options) #

View source

#push #

View source

#results : Array(String) #

View source

#results=(results : Array(String)) #

View source