Class: Messenger::Elements::Bubble

Inherits:
Object
  • Object
show all
Includes:
Components::Element
Defined in:
lib/messenger/components/elements/bubble.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Components::Element

#build, #build_elements

Constructor Details

#initialize(title:, subtitle: nil, item_url: nil, image_url: nil, buttons: nil) ⇒ Bubble

Returns a new instance of Bubble.



10
11
12
13
14
15
16
# File 'lib/messenger/components/elements/bubble.rb', line 10

def initialize(title:, subtitle: nil, item_url: nil, image_url: nil, buttons: nil)
  @title     = title
  @subtitle  = subtitle
  @image_url = image_url
  @item_url  = item_url
  @buttons   = build_buttons(buttons)
end

Instance Attribute Details

#buttonsObject

Returns the value of attribute buttons.



8
9
10
# File 'lib/messenger/components/elements/bubble.rb', line 8

def buttons
  @buttons
end

#image_urlObject

Returns the value of attribute image_url.



8
9
10
# File 'lib/messenger/components/elements/bubble.rb', line 8

def image_url
  @image_url
end

#item_urlObject

Returns the value of attribute item_url.



8
9
10
# File 'lib/messenger/components/elements/bubble.rb', line 8

def item_url
  @item_url
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/messenger/components/elements/bubble.rb', line 8

def title
  @title
end

Instance Method Details

#build_buttons(buttons) ⇒ Object



18
19
20
# File 'lib/messenger/components/elements/bubble.rb', line 18

def build_buttons(buttons)
  buttons.map { |button| button.build } if buttons.present?
end