Class: Docxtor::Document::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/docxtor/document/element.rb

Direct Known Subclasses

PageBreak, Paragraph, Root, TableOfContents

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#elementsObject

Returns the value of attribute elements.



4
5
6
# File 'lib/docxtor/document/element.rb', line 4

def elements
  @elements
end

#xmlObject

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