Module: Scale::Node
- Includes:
- Enumerable
- Defined in:
- lib/scale/node.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #add(node) ⇒ Object
- #append_to(builder) ⇒ Object
- #children ⇒ Object
- #each ⇒ Object
- #to_xml ⇒ Object
- #xml_attributes ⇒ Object
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/scale/node.rb', line 7 def content @content end |
Instance Method Details
#add(node) ⇒ Object
13 14 15 |
# File 'lib/scale/node.rb', line 13 def add(node) children.push(node) end |
#append_to(builder) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/scale/node.rb', line 30 def append_to(builder) builder.send(xml_tag.to_sym, *xml_parameters) do each do |node| node.append_to(builder) end end end |
#children ⇒ Object
9 10 11 |
# File 'lib/scale/node.rb', line 9 def children @children ||= [] end |
#each ⇒ Object
17 18 19 20 21 |
# File 'lib/scale/node.rb', line 17 def each children.each do |child| yield child end end |
#to_xml ⇒ Object
23 24 25 26 27 28 |
# File 'lib/scale/node.rb', line 23 def to_xml builder = Nokogiri::XML::Builder.new do |xml| append_to(xml) end builder.to_xml end |
#xml_attributes ⇒ Object
38 39 40 |
# File 'lib/scale/node.rb', line 38 def xml_attributes attributes.delete_if { |key, value| value.nil? } end |