Sha256: b20edfd767cba202c653f9bff9d43a422884394e7fb22a3660949d5c058cc917
Contents?: true
Size: 790 Bytes
Versions: 2
Compression:
Stored size: 790 Bytes
Contents
module Pump class Xml class Node attr_reader :name, :attributes, :nodes, :options attr_writer :level def initialize(name, attributes={}, nodes=[], options={}) @name = name @attributes = attributes || {} @options = (options || {}).dup @nodes = [] Array(nodes).each{|node| add_node(node) } end def to_s end private def add_node(node) node.level = level + 1 node.options[:extra_indent] = options[:extra_indent] nodes << node end def level @level || options[:level] || 0 end def tabs " " * ((level + extra_indent) * 2) end def extra_indent options[:extra_indent] || 0 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pump-0.0.3 | lib/pump/xml/node.rb |
pump-0.0.2 | lib/pump/xml/node.rb |