class Pump::Xml::Node

Attributes

attributes[R]
name[R]
nodes[R]
options[R]

Public Class Methods

new(name, attributes={}, nodes=[], options={}) click to toggle source
# File lib/pump/xml/node.rb, line 6
def initialize(name, attributes={}, nodes=[], options={})
  @name       = name
  @attributes = attributes || {}
  @options    = (options || {}).dup
  @nodes      = []
  Array(nodes).each{|node| add_node(node) }
end

Public Instance Methods

level=(new_level) click to toggle source
# File lib/pump/xml/node.rb, line 17
def level=(new_level)
  @level = new_level
  nodes.each{|node| node.level = @level + 1}
end
to_s() click to toggle source
# File lib/pump/xml/node.rb, line 14
def to_s
end

Private Instance Methods

add_node(node) click to toggle source
# File lib/pump/xml/node.rb, line 24
def add_node(node)
  node.level = level + 1
  node.options[:extra_indent] = options[:extra_indent]
  node.options[:xml_key_style] = options[:xml_key_style]
  nodes << node
end
extra_indent() click to toggle source
# File lib/pump/xml/node.rb, line 39
def extra_indent
  options[:extra_indent] || 0
end
format_name(name) click to toggle source
# File lib/pump/xml/node.rb, line 43
def format_name(name)
  return name.to_s.underscore if options[:xml_key_style] == :underscores
  name.to_s.dasherize
end
level() click to toggle source
# File lib/pump/xml/node.rb, line 31
def level
  @level || options[:level] || 0
end
tabs() click to toggle source
# File lib/pump/xml/node.rb, line 35
def tabs
  " " * ((level + extra_indent) * 2)
end