Class: Ruote::XmlReader::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ruote/reader/xml.rb

Overview

A helper class to store the temporary tree while it gets read.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, name, atts) ⇒ Node


50
51
52
53
54
55
56
57
58
# File 'lib/ruote/reader/xml.rb', line 50

def initialize(parent, name, atts)

  @parent = parent
  @name = name
  @attributes = atts.remap { |(k, v), h| h[k.gsub(/-/, '_')] = v }
  @children = []

  parent.children << self if parent
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes


48
49
50
# File 'lib/ruote/reader/xml.rb', line 48

def attributes
  @attributes
end

#childrenObject (readonly)

Returns the value of attribute children


48
49
50
# File 'lib/ruote/reader/xml.rb', line 48

def children
  @children
end

#parentObject (readonly)

Returns the value of attribute parent


48
49
50
# File 'lib/ruote/reader/xml.rb', line 48

def parent
  @parent
end

Instance Method Details

#to_aObject


60
61
62
63
# File 'lib/ruote/reader/xml.rb', line 60

def to_a

  [ @name, @attributes, @children.collect { |c| c.to_a } ]
end