Class: DocxGenerator::DSL::Paragraph
- Inherits:
-
Object
- Object
- DocxGenerator::DSL::Paragraph
- Defined in:
- lib/docx_generator/dsl/paragraph.rb
Instance Method Summary collapse
- #add(*objects) ⇒ Object
- #alignment(value) ⇒ Object
- #generate ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Paragraph
constructor
A new instance of Paragraph.
- #no_space ⇒ Object
- #text(text_fragment, options = {}) {|text_object| ... } ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Paragraph
Returns a new instance of Paragraph.
4 5 6 7 8 |
# File 'lib/docx_generator/dsl/paragraph.rb', line 4 def initialize( = {}, &block) @objects = [] @options = yield self if block end |
Instance Method Details
#add(*objects) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/docx_generator/dsl/paragraph.rb', line 34 def add(*objects) objects.each do |object| @objects << object end self end |
#alignment(value) ⇒ Object
10 11 12 |
# File 'lib/docx_generator/dsl/paragraph.rb', line 10 def alignment(value) @options[:alignment] = value end |
#generate ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/docx_generator/dsl/paragraph.rb', line 24 def generate text_fragments = generate_text_fragments = if Word::Paragraph.new({}, text_fragments.unshift()) else Word::Paragraph.new({}, text_fragments) end end |
#no_space ⇒ Object
14 15 16 |
# File 'lib/docx_generator/dsl/paragraph.rb', line 14 def no_space @objects << DocxGenerator::Word::Extensions::NoSpace.new end |
#text(text_fragment, options = {}) {|text_object| ... } ⇒ Object
18 19 20 21 22 |
# File 'lib/docx_generator/dsl/paragraph.rb', line 18 def text(text_fragment, = {}, &block) text_object = DocxGenerator::DSL::Text.new(text_fragment, ) yield text_object if block @objects << text_object end |