Class: OxmlMaker::Paragraph
- Inherits:
-
Object
- Object
- OxmlMaker::Paragraph
- Defined in:
- lib/oxml_maker/paragraph.rb
Overview
Represents a paragraph in an OXML document. It can be used to create structured text content within a Word document. The class is initialized with data that will be used to populate the paragraph.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #template ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Paragraph
Returns a new instance of Paragraph.
16 17 18 19 20 |
# File 'lib/oxml_maker/paragraph.rb', line 16 def initialize(data = {}) raise ArgumentError, "Data must be a Hash" unless data.is_a?(Hash) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/oxml_maker/paragraph.rb', line 14 def data @data end |
Instance Method Details
#template ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/oxml_maker/paragraph.rb', line 22 def template <<~XML <w:p> <w:r> <w:t>#{data[:text]}</w:t> </w:r> </w:p> XML end |