Class: Rubyword::Element::Paragraph
- Defined in:
- lib/rubyword/element/paragraph.rb
Constant Summary
Constants inherited from Text
Instance Attribute Summary collapse
-
#paragraphs ⇒ Object
Returns the value of attribute paragraphs.
-
#style ⇒ Object
Returns the value of attribute style.
Attributes inherited from Text
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(rubyword, section = nil, style) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #method_missing(name, *arg) ⇒ Object
- #text(text, style = nil) ⇒ Object
- #write(section = nil, xml = nil) ⇒ Object
Methods inherited from Text
Methods inherited from Base
Constructor Details
#initialize(rubyword, section = nil, style) ⇒ Paragraph
Returns a new instance of Paragraph.
6 7 8 9 |
# File 'lib/rubyword/element/paragraph.rb', line 6 def initialize(rubyword, section=nil, style) super(rubyword, section) @style = style end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arg) ⇒ Object
33 34 35 |
# File 'lib/rubyword/element/paragraph.rb', line 33 def method_missing(name, *arg) @section.send(name.to_sym, *arg) end |
Instance Attribute Details
#paragraphs ⇒ Object
Returns the value of attribute paragraphs.
5 6 7 |
# File 'lib/rubyword/element/paragraph.rb', line 5 def paragraphs @paragraphs end |
#style ⇒ Object
Returns the value of attribute style.
5 6 7 |
# File 'lib/rubyword/element/paragraph.rb', line 5 def style @style end |
Instance Method Details
#text(text, style = nil) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rubyword/element/paragraph.rb', line 11 def text(text, style=nil) @paragraphs ||= [] text = filter_text(text) @paragraphs << { text: text, style: style } end |
#write(section = nil, xml = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubyword/element/paragraph.rb', line 20 def write(section=nil, xml=nil) @xml = xml @xml.send('w:p') { @paragraphs.each do |p| Writer::Style::Paragraph.new(@section, @xml, @rubyword).write(p[:style]) @xml.send('w:r') do Writer::Style::Word.new(@section, @xml, @rubyword).write(p[:style]) @xml.send('w:t', {'xml:space' => 'preserve'}, p[:text]) end end } end |