Class: Slack::BlockKit::Layout::RichText::RichTextPreformatted

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

Overview

Constant Summary collapse

TYPE =
'rich_text_preformatted'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RichTextElements

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

Constructor Details

#initialize(border: nil) {|_self| ... } ⇒ RichTextPreformatted

Returns a new instance of RichTextPreformatted.

Yields:

  • (_self)

Yield Parameters:



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

def initialize(border: nil)
  @elements = []
  @border = border

  yield(self) if block_given?
end

Instance Attribute Details

#borderObject

Returns the value of attribute border.



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

def border
  @border
end

#elementsObject

Returns the value of attribute elements.



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

def elements
  @elements
end

Instance Method Details

#append(element) ⇒ Object



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

def append(element)
  @elements << element

  self
end

#as_jsonObject



27
28
29
30
31
32
33
# File 'lib/slack/block_kit/layout/rich_text/rich_text_preformatted.rb', line 27

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