Class: MsTeamsHermes::Components::AdaptiveCard
- Defined in:
- lib/msteams_hermes/components/adaptive_card.rb
Overview
A class representing Microsoft’s AdaptiveCard object adaptivecards.io/explorer/AdaptiveCard.html
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#entities ⇒ Object
readonly
Returns the value of attribute entities.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(body:, actions: nil, entities: [], width: Style::Width::DEFAULT) ⇒ AdaptiveCard
constructor
A new instance of AdaptiveCard.
- #to_hash ⇒ Object
Constructor Details
#initialize(body:, actions: nil, entities: [], width: Style::Width::DEFAULT) ⇒ AdaptiveCard
Returns a new instance of AdaptiveCard.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/msteams_hermes/components/adaptive_card.rb', line 19 def initialize(body:, actions: nil, entities: [], width: Style::Width::DEFAULT) @body = body raise "AdaptiveCard `body` must be an Array" unless @body.is_a? Array @actions = actions raise "AdaptiveCard `actions` must be an Array" unless @actions.nil? || @actions.is_a?(Array) @entities = entities raise "AdaptiveCard `entities` must be an Array" unless @entities.nil? || @entities.is_a?(Array) @width = width raise "AdaptiveCard `width` must be one of the available Width options" unless Style::Width.all.include?(width) end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
17 18 19 |
# File 'lib/msteams_hermes/components/adaptive_card.rb', line 17 def actions @actions end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
17 18 19 |
# File 'lib/msteams_hermes/components/adaptive_card.rb', line 17 def body @body end |
#entities ⇒ Object (readonly)
Returns the value of attribute entities.
17 18 19 |
# File 'lib/msteams_hermes/components/adaptive_card.rb', line 17 def entities @entities end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
17 18 19 |
# File 'lib/msteams_hermes/components/adaptive_card.rb', line 17 def width @width end |
Instance Method Details
#to_hash ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/msteams_hermes/components/adaptive_card.rb', line 33 def to_hash { type: "AdaptiveCard", version: "1.5", body: body.map(&:to_hash), actions: actions&.map(&:to_hash), msteams: { entities: entities.map(&:to_hash), width: } } end |