Class: BlockKit::Layout::RichText
- 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
Instance Method Summary collapse
- #append(element) ⇒ Object
- #as_json ⇒ Object
-
#initialize(attributes = {}) ⇒ RichText
constructor
A new instance of RichText.
Methods inherited from Base
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_json ⇒ Object
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 |