Class: Docxtor::Document::Element
- Inherits:
-
Object
- Object
- Docxtor::Document::Element
- Defined in:
- lib/docxtor/document/element.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#xml ⇒ Object
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Element
constructor
A new instance of Element.
- #method_missing(name, *args) ⇒ Object
- #render(xml) ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Element
Returns a new instance of Element.
18 19 20 21 22 23 24 25 |
# File 'lib/docxtor/document/element.rb', line 18 def initialize(*args, &block) @elements = [] # FIXME You have to call #create_params in this hook after_initialize(*args) instance_eval &block if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
14 15 16 |
# File 'lib/docxtor/document/element.rb', line 14 def method_missing name, *args super unless [:header, :footer].include? name end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
4 5 6 |
# File 'lib/docxtor/document/element.rb', line 4 def elements @elements end |
#xml ⇒ Object
Returns the value of attribute xml.
4 5 6 |
# File 'lib/docxtor/document/element.rb', line 4 def xml @xml end |
Class Method Details
.map(mappings) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/docxtor/document/element.rb', line 6 def self.map(mappings) mappings.each do |name, klass| define_method(name) do |*args, &block| elements << klass.new(*args, &block) end end end |
Instance Method Details
#render(xml) ⇒ Object
27 28 29 |
# File 'lib/docxtor/document/element.rb', line 27 def render(xml) @xml = xml end |