Class: Uniword::Builder::ListBuilder
- Inherits:
-
Object
- Object
- Uniword::Builder::ListBuilder
- Defined in:
- lib/uniword/builder/list_builder.rb
Overview
Builds lists (bulleted or numbered) within a document.
Instance Attribute Summary collapse
-
#num_id ⇒ Integer
readonly
The numbering ID assigned to this list.
-
#type ⇒ Symbol
readonly
The list type (:bullet, :decimal, :roman, :letter).
Instance Method Summary collapse
-
#initialize(document, type: :bullet) ⇒ ListBuilder
constructor
A new instance of ListBuilder.
-
#item(text = nil, level: 0) {|ParagraphBuilder| ... } ⇒ ParagraphBuilder
Add an item to the list.
Constructor Details
#initialize(document, type: :bullet) ⇒ ListBuilder
Returns a new instance of ListBuilder.
27 28 29 30 31 32 33 34 |
# File 'lib/uniword/builder/list_builder.rb', line 27 def initialize(document, type: :bullet) @document = document @type = type model = document.model model.numbering_configuration ||= Uniword::Wordprocessingml::NumberingConfiguration.new @num_id = model.numbering_configuration .create_numbering(type) end |
Instance Attribute Details
#num_id ⇒ Integer (readonly)
Returns The numbering ID assigned to this list.
22 23 24 |
# File 'lib/uniword/builder/list_builder.rb', line 22 def num_id @num_id end |
#type ⇒ Symbol (readonly)
Returns The list type (:bullet, :decimal, :roman, :letter).
25 26 27 |
# File 'lib/uniword/builder/list_builder.rb', line 25 def type @type end |
Instance Method Details
#item(text = nil, level: 0) {|ParagraphBuilder| ... } ⇒ ParagraphBuilder
Add an item to the list
42 43 44 45 46 47 48 49 |
# File 'lib/uniword/builder/list_builder.rb', line 42 def item(text = nil, level: 0, &block) para = ParagraphBuilder.new para.numbering(@num_id, level) para << text if text yield(para) if block @document << para.build para end |