Class: BlockKit::Layout::RichText

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

Defined Under Namespace

Modules: Elements Classes: List, Preformatted, Quote, Section

Constant Summary collapse

SUPPORTED_ELEMENTS =
[
  RichText::List,
  RichText::Preformatted,
  RichText::Quote,
  RichText::Section
].freeze

Constants inherited from Base

Base::MAX_BLOCK_ID_LENGTH

Instance Method Summary collapse

Methods inherited from Base

inherited

Methods inherited from Base

#==, fix, #fix_validation_errors, #fix_validation_errors!, fixes, inherited, inspect, #inspect, #pretty_print, #to_json

Constructor Details

#initialize(attributes = {}) ⇒ RichText

Returns a new instance of RichText.



35
36
37
38
39
40
# File 'lib/block_kit/layout/rich_text.rb', line 35

def initialize(attributes = {})
  attributes = attributes.with_indifferent_access
  attributes[:elements] ||= []

  super
end

Instance Method Details

#append(element) ⇒ Object



42
43
44
45
46
# File 'lib/block_kit/layout/rich_text.rb', line 42

def append(element)
  elements << element

  self
end

#as_jsonObject



48
49
50
# File 'lib/block_kit/layout/rich_text.rb', line 48

def as_json(*)
  super.merge(elements: elements&.map(&:as_json)).compact
end