Class: TelegramOnSteroids::Keyboard

Inherits:
Object
  • Object
show all
Extended by:
Configurable
Defined in:
lib/telegram_on_steroids/keyboard.rb

Direct Known Subclasses

Inline

Defined Under Namespace

Modules: Paginatable Classes: Button, Inline, Row

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

callable, configure

Constructor Details

#initialize(request:, action:) ⇒ Keyboard

Returns a new instance of Keyboard.



7
8
9
10
11
12
# File 'lib/telegram_on_steroids/keyboard.rb', line 7

def initialize(request:, action:)
  @request = request
  @buttons = []
  @action = action
  after_initialize
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



30
31
32
# File 'lib/telegram_on_steroids/keyboard.rb', line 30

def action
  @action
end

#buttonsObject (readonly)

Returns the value of attribute buttons.



30
31
32
# File 'lib/telegram_on_steroids/keyboard.rb', line 30

def buttons
  @buttons
end

#requestObject (readonly)

Returns the value of attribute request.



30
31
32
# File 'lib/telegram_on_steroids/keyboard.rb', line 30

def request
  @request
end

Instance Method Details

#after_initializeObject



14
# File 'lib/telegram_on_steroids/keyboard.rb', line 14

def after_initialize; end

#button(**button) ⇒ Object



16
17
18
# File 'lib/telegram_on_steroids/keyboard.rb', line 16

def button(**button)
  @buttons.push([Button.new(**button, keyboard: self).to_telegram_format])
end

#row {|row| ... } ⇒ Object

Yields:



20
21
22
23
24
# File 'lib/telegram_on_steroids/keyboard.rb', line 20

def row
  row = Row.new(keyboard: self)
  yield row
  buttons.push(row.buttons)
end

#to_telegram_formatObject



26
27
28
# File 'lib/telegram_on_steroids/keyboard.rb', line 26

def to_telegram_format
  buttons
end