Class: XmlHasher::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Node

Returns a new instance of Node.



7
8
9
10
11
# File 'lib/xmlhasher/node.rb', line 7

def initialize(name)
  @name = name
  @attributes = {}
  @children = []
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



5
6
7
# File 'lib/xmlhasher/node.rb', line 5

def attributes
  @attributes
end

#childrenObject

Returns the value of attribute children.



5
6
7
# File 'lib/xmlhasher/node.rb', line 5

def children
  @children
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/xmlhasher/node.rb', line 5

def name
  @name
end

#textObject

Returns the value of attribute text.



5
6
7
# File 'lib/xmlhasher/node.rb', line 5

def text
  @text
end

Instance Method Details

#to_hashObject



13
14
15
16
# File 'lib/xmlhasher/node.rb', line 13

def to_hash
  node_content = content
  { name => node_content.empty? ? nil : node_content }
end