Sha256: 17ddaa36f9e6014c76a73a0f1d37d1793f02a560485d7f7b89101e7fc67b94aa
Contents?: true
Size: 882 Bytes
Versions: 9
Compression:
Stored size: 882 Bytes
Contents
module Pump class Xml class Node attr_reader :name, :attributes, :nodes, :options 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 def level=(new_level) @level = new_level nodes.each{|node| node.level = @level + 1} 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
9 entries across 9 versions & 1 rubygems