Class: Slack::BlockKit::Layout::RichText::RichTextSection

Inherits:
Object
  • Object
show all
Includes:
RichTextElements
Defined in:
lib/slack/block_kit/layout/rich_text/rich_text_section.rb

Overview

Constant Summary collapse

TYPE =
'rich_text_section'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RichTextElements

#channel, #emoji, #link, #text, #user, #usergroup

Constructor Details

#initialize {|_self| ... } ⇒ RichTextSection

Returns a new instance of RichTextSection.

Yields:

  • (_self)

Yield Parameters:



14
15
16
17
18
# File 'lib/slack/block_kit/layout/rich_text/rich_text_section.rb', line 14

def initialize
  @elements = []

  yield(self) if block_given?
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



12
13
14
# File 'lib/slack/block_kit/layout/rich_text/rich_text_section.rb', line 12

def elements
  @elements
end

Instance Method Details

#append(element) ⇒ Object



20
21
22
23
24
# File 'lib/slack/block_kit/layout/rich_text/rich_text_section.rb', line 20

def append(element)
  @elements << element

  self
end

#as_jsonObject



26
27
28
29
30
31
# File 'lib/slack/block_kit/layout/rich_text/rich_text_section.rb', line 26

def as_json(*)
  {
    type: TYPE,
    elements: @elements.map(&:as_json)
  }.compact
end