Module: OpenXml::HasChildren
- Defined in:
- lib/openxml/has_children.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #<<(child) ⇒ Object
- #initialize ⇒ Object
- #push(child) ⇒ Object
- #render? ⇒ Boolean
- #to_xml(xml) ⇒ Object
Instance Attribute Details
#children ⇒ Object (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
10 11 12 |
# File 'lib/openxml/has_children.rb', line 10 def <<(child) children << child end |
#initialize ⇒ Object
5 6 7 8 |
# File 'lib/openxml/has_children.rb', line 5 def initialize(*) super @children = [] end |
#push(child) ⇒ Object
14 15 16 |
# File 'lib/openxml/has_children.rb', line 14 def push(child) children.push(child) end |
#render? ⇒ Boolean
27 28 29 |
# File 'lib/openxml/has_children.rb', line 27 def render? super || children.any? end |
#to_xml(xml) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/openxml/has_children.rb', line 18 def to_xml(xml) super(xml) do yield xml if block_given? children.each do |child| child.to_xml(xml) end end end |