Class: Slack::BlockKit::Layout::RichText::RichTextList

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

Overview

Constant Summary collapse

TYPE =
'rich_text_list'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(style:, indent: nil, offset: nil, border: nil) {|_self| ... } ⇒ RichTextList

Returns a new instance of RichTextList.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
20
21
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 13

def initialize(style:, indent: nil, offset: nil, border: nil)
  @elements = []
  @style = style
  @indent = indent
  @offset = offset
  @border = border

  yield(self) if block_given?
end

Instance Attribute Details

#borderObject

Returns the value of attribute border.



11
12
13
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 11

def border
  @border
end

#elementsObject

Returns the value of attribute elements.



11
12
13
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 11

def elements
  @elements
end

#indentObject

Returns the value of attribute indent.



11
12
13
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 11

def indent
  @indent
end

#offsetObject

Returns the value of attribute offset.



11
12
13
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 11

def offset
  @offset
end

#styleObject

Returns the value of attribute style.



11
12
13
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 11

def style
  @style
end

Instance Method Details

#append(element) ⇒ Object



31
32
33
34
35
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 31

def append(element)
  @elements << element

  self
end

#as_jsonObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 37

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

#rich_text_section {|element| ... } ⇒ Object

Yields:

  • (element)


23
24
25
26
27
28
29
# File 'lib/slack/block_kit/layout/rich_text/rich_text_list.rb', line 23

def rich_text_section
  element = RichTextSection.new

  yield(element) if block_given?

  append(element)
end