Class: Messenger::Elements::Button

Inherits:
Object
  • Object
show all
Defined in:
lib/messenger/components/elements/button.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/messenger/components/elements/button.rb', line 4

def title
  @title
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/messenger/components/elements/button.rb', line 4

def type
  @type
end

#valueObject

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

#buildObject



12
13
14
# File 'lib/messenger/components/elements/button.rb', line 12

def build
  { type: @type, title: @title }.merge! eval(@type.to_s)
end

#postbackObject



20
21
22
# File 'lib/messenger/components/elements/button.rb', line 20

def postback
  { payload: @value }
end

#web_urlObject



16
17
18
# File 'lib/messenger/components/elements/button.rb', line 16

def web_url
  { url: @value }
end