Class: TelegramOnSteroids::Keyboard::Button

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

callable, configure

Constructor Details

#initialize(text:, callback_data:, keyboard:) ⇒ Button

Returns a new instance of Button.



4
5
6
7
8
# File 'lib/telegram_on_steroids/keyboard/button.rb', line 4

def initialize(text:, callback_data:, keyboard:)
  @text = text
  @callback_data = callback_data
  @keyboard = keyboard
end

Instance Attribute Details

#callback_dataObject (readonly)

Returns the value of attribute callback_data.



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

def callback_data
  @callback_data
end

#keyboardObject (readonly)

Returns the value of attribute keyboard.



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

def keyboard
  @keyboard
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#to_telegram_formatObject



10
11
12
13
# File 'lib/telegram_on_steroids/keyboard/button.rb', line 10

def to_telegram_format
  text = @text.is_a?(Proc) ? keyboard.instance_eval(&@text) : @text
  { text:, callback_data: }
end