Class: Arrolio::Content::Builder
- Inherits:
-
Object
- Object
- Arrolio::Content::Builder
- Defined in:
- lib/arrolio/content/builder.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(metadata: {}) ⇒ Builder
constructor
A new instance of Builder.
- #section(title = nil, number: nil, level: 1, id: nil, style_id: :section_body, title_style_id: nil, &block) ⇒ Object
- #to_document ⇒ Object
Constructor Details
#initialize(metadata: {}) ⇒ Builder
Returns a new instance of Builder.
14 15 16 17 |
# File 'lib/arrolio/content/builder.rb', line 14 def initialize(metadata: {}) @metadata = @sections = [] end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/arrolio/content/builder.rb', line 6 def @metadata end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
6 7 8 |
# File 'lib/arrolio/content/builder.rb', line 6 def sections @sections end |
Class Method Details
.build(metadata: {}, **opts, &block) ⇒ Object
8 9 10 11 12 |
# File 'lib/arrolio/content/builder.rb', line 8 def self.build(metadata: {}, **opts, &block) builder = new(metadata: , **opts) block&.call(builder) builder.to_document end |
Instance Method Details
#section(title = nil, number: nil, level: 1, id: nil, style_id: :section_body, title_style_id: nil, &block) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/arrolio/content/builder.rb', line 19 def section(title = nil, number: nil, level: 1, id: nil, style_id: :section_body, title_style_id: nil, &block) sb = SectionBuilder.new(title: title, number: number, level: level, id: id, style_id: style_id, title_style_id: title_style_id) block&.call(sb) @sections << sb.build self end |