Class: MsTeamsHermes::Components::TextBlock

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, wrap: false, color: Style::Colors::DEFAULT, size: Style::FontSize::DEFAULT, font_type: Style::FontType::DEFAULT, weight: Style::FontWeight::DEFAULT, is_subtle: false) ⇒ TextBlock

Returns a new instance of TextBlock.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/msteams_hermes/components/text_block.rb', line 19

def initialize(text:,
               wrap: false,
               color: Style::Colors::DEFAULT,
               size: Style::FontSize::DEFAULT,
               font_type: Style::FontType::DEFAULT,
               weight: Style::FontWeight::DEFAULT,
               is_subtle: false)
  @text = text
  raise "TextBlock `text` must be a String" unless @text.is_a? String

  @wrap = wrap
  @color = color
  @size = size
  @font_type = font_type
  @weight = weight
  @is_subtle = is_subtle
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



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

def color
  @color
end

#font_typeObject (readonly)

Returns the value of attribute font_type.



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

def font_type
  @font_type
end

#is_subtleObject (readonly)

Returns the value of attribute is_subtle.



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

def is_subtle
  @is_subtle
end

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#weightObject (readonly)

Returns the value of attribute weight.



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

def weight
  @weight
end

#wrapObject (readonly)

Returns the value of attribute wrap.



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

def wrap
  @wrap
end

Instance Method Details

#to_hashObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/msteams_hermes/components/text_block.rb', line 37

def to_hash
  {
    type: "TextBlock",
    text:,
    color:,
    size:,
    font_type:,
    weight:,
    wrap:,
    is_subtle:
  }
end