Class: Slack::BlockKit::Layout::RichText::RichTextElements::Text

Inherits:
Object
  • Object
show all
Includes:
StyleHelper
Defined in:
lib/slack/block_kit/layout/rich_text/rich_text_elements/text.rb

Overview

Constant Summary collapse

TYPE =
'text'
VALID_STYLES =
%w[bold italic strike code].freeze

Instance Method Summary collapse

Methods included from StyleHelper

#styles_as_json, #validate_styles

Constructor Details

#initialize(text:, styles: []) ⇒ Text

Returns a new instance of Text.



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

def initialize(text:, styles: [])
  @text = text
  @styles = styles
  validate_styles(styles, VALID_STYLES)
end

Instance Method Details

#as_jsonObject



20
21
22
23
24
25
26
# File 'lib/slack/block_kit/layout/rich_text/rich_text_elements/text.rb', line 20

def as_json(*)
  {
    type: TYPE,
    text: @text,
    style: styles_as_json(@styles)
  }.compact
end