Class: Slocks::RichTextBuilder
- Inherits:
-
Object
- Object
- Slocks::RichTextBuilder
- Defined in:
- lib/slocks/rich_text_builder.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Instance Method Summary collapse
-
#initialize ⇒ RichTextBuilder
constructor
A new instance of RichTextBuilder.
- #list(style:, &block) ⇒ Object
- #preformatted(&block) ⇒ Object
- #quote(&block) ⇒ Object
- #section(&block) ⇒ Object
Constructor Details
#initialize ⇒ RichTextBuilder
Returns a new instance of RichTextBuilder.
7 8 9 |
# File 'lib/slocks/rich_text_builder.rb', line 7 def initialize @elements = [] end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
5 6 7 |
# File 'lib/slocks/rich_text_builder.rb', line 5 def elements @elements end |
Instance Method Details
#list(style:, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/slocks/rich_text_builder.rb', line 20 def list(style:, &block) list_builder = RichTextSectionBuilder.new list_builder.instance_eval(&block) if block_given? @elements << { type: "rich_text_list", style: style, elements: list_builder.elements } end |
#preformatted(&block) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/slocks/rich_text_builder.rb', line 30 def preformatted(&block) section_builder = RichTextSectionBuilder.new section_builder.instance_eval(&block) if block_given? @elements << { type: "rich_text_preformatted", elements: section_builder.elements } end |
#quote(&block) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/slocks/rich_text_builder.rb', line 39 def quote(&block) section_builder = RichTextSectionBuilder.new section_builder.instance_eval(&block) if block_given? @elements << { type: "rich_text_quote", elements: section_builder.elements } end |
#section(&block) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/slocks/rich_text_builder.rb', line 11 def section(&block) section_builder = RichTextSectionBuilder.new section_builder.instance_eval(&block) if block_given? @elements << { type: "rich_text_section", elements: section_builder.elements } end |