Module: OpenXml::HasChildren

Defined in:
lib/openxml/has_children.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



3
4
5
# File 'lib/openxml/has_children.rb', line 3

def children
  @children
end

Instance Method Details

#<<(child) ⇒ Object



9
10
11
# File 'lib/openxml/has_children.rb', line 9

def <<(child)
  children << child
end

#initializeObject



5
6
7
# File 'lib/openxml/has_children.rb', line 5

def initialize
  @children = []
end

#push(child) ⇒ Object



13
14
15
# File 'lib/openxml/has_children.rb', line 13

def push(child)
  children.push(child)
end

#render?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/openxml/has_children.rb', line 26

def render?
  super || children.any?
end

#to_xml(xml) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/openxml/has_children.rb', line 17

def to_xml(xml)
  super(xml) do
    yield xml if block_given?
    children.each do |child|
      child.to_xml(xml)
    end
  end
end