module Scale::Node
Attributes
content[R]
Public Instance Methods
add(node)
click to toggle source
# File lib/scale/node.rb, line 14 def add(node) children.push(node) end
append_to(builder)
click to toggle source
# File lib/scale/node.rb, line 31 def append_to(builder) builder.send(xml_tag.to_sym, *xml_parameters) do each do |node| node.append_to(builder) end end end
children()
click to toggle source
# File lib/scale/node.rb, line 10 def children @children ||= [] end
each() { |child| ... }
click to toggle source
# File lib/scale/node.rb, line 18 def each children.each do |child| yield child end end
to_xml()
click to toggle source
# File lib/scale/node.rb, line 24 def to_xml builder = Nokogiri::XML::Builder.new do |xml| append_to(xml) end builder.to_xml end
xml_attributes()
click to toggle source
# File lib/scale/node.rb, line 39 def xml_attributes attributes.inject({}) do |memo, (key, value)| new_key = key.to_s.gsub(/\_/, "-").to_sym memo[new_key] = value unless value.nil? memo end end
Private Instance Methods
xml_parameters()
click to toggle source
# File lib/scale/node.rb, line 49 def xml_parameters return [xml_attributes] if content.nil? [content, xml_attributes] end