Class: Pump::Xml::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/pump/xml/node.rb

Direct Known Subclasses

Tag, TagArray, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes = {}, nodes = [], options = {}) ⇒ Node

Returns a new instance of Node.



6
7
8
9
10
11
12
# 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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/pump/xml/node.rb', line 4

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/pump/xml/node.rb', line 4

def name
  @name
end

#nodesObject (readonly)

Returns the value of attribute nodes.



4
5
6
# File 'lib/pump/xml/node.rb', line 4

def nodes
  @nodes
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/pump/xml/node.rb', line 4

def options
  @options
end

Instance Method Details

#level=(new_level) ⇒ Object



17
18
19
20
# File 'lib/pump/xml/node.rb', line 17

def level=(new_level)
  @level = new_level
  nodes.each{|node| node.level = @level + 1}
end

#to_sObject



14
15
# File 'lib/pump/xml/node.rb', line 14

def to_s
end