Class: MsTeamsHermes::Components::Container

Inherits:
Base
  • Object
show all
Defined in:
lib/msteams_hermes/components/container.rb

Overview

A class representing Microsoft’s Container object adaptivecards.io/explorer/Container.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items:, style: Style::ContainerStyle::DEFAULT, select_action: nil) ⇒ Container

Returns a new instance of Container.



19
20
21
22
23
24
25
# File 'lib/msteams_hermes/components/container.rb', line 19

def initialize(items:, style: Style::ContainerStyle::DEFAULT, select_action: nil)
  @items = items
  raise "Container `items` must be an Array" unless @items.is_a? Array

  @style = style
  @select_action = select_action
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



17
18
19
# File 'lib/msteams_hermes/components/container.rb', line 17

def items
  @items
end

#select_actionObject (readonly)

Returns the value of attribute select_action.



17
18
19
# File 'lib/msteams_hermes/components/container.rb', line 17

def select_action
  @select_action
end

#styleObject (readonly)

Returns the value of attribute style.



17
18
19
# File 'lib/msteams_hermes/components/container.rb', line 17

def style
  @style
end

Instance Method Details

#to_hashObject



27
28
29
30
31
32
33
34
# File 'lib/msteams_hermes/components/container.rb', line 27

def to_hash
  {
    type: "Container",
    style:,
    selectAction: select_action&.to_hash,
    items: items.map(&:to_hash)
  }
end