Class: Messenger::Elements::Button
- Inherits:
-
Object
- Object
- Messenger::Elements::Button
- Defined in:
- lib/messenger/components/elements/button.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(type:, title:, value:) ⇒ Button
constructor
A new instance of Button.
- #postback ⇒ Object
- #web_url ⇒ Object
Constructor Details
#initialize(type:, title:, value:) ⇒ Button
Returns a new instance of Button.
6 7 8 9 10 |
# File 'lib/messenger/components/elements/button.rb', line 6 def initialize(type:, title:, value:) @type = type @title = title @value = value end |
Instance Attribute Details
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/messenger/components/elements/button.rb', line 4 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/messenger/components/elements/button.rb', line 4 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/messenger/components/elements/button.rb', line 4 def value @value end |
Instance Method Details
#build ⇒ Object
12 13 14 |
# File 'lib/messenger/components/elements/button.rb', line 12 def build { type: @type, title: @title }.merge! eval(@type.to_s) end |
#postback ⇒ Object
20 21 22 |
# File 'lib/messenger/components/elements/button.rb', line 20 def postback { payload: @value } end |
#web_url ⇒ Object
16 17 18 |
# File 'lib/messenger/components/elements/button.rb', line 16 def web_url { url: @value } end |