class Onde::Node

Attributes

alias[R]
children[R]
path[R]

Public Class Methods

new(data, parent_path=nil) click to toggle source
# File lib/onde.rb, line 99
def initialize(data, parent_path=nil)
  unless data.is_a? Array
    raise Onde::ConfigurationError.new("Node #{data} is not properly formed")
  end
  node_data, child_data = data
  if node_data.is_a? Hash
    @alias = node_data.keys()[0]
    path_part = node_data[@alias]
  elsif node_data.is_a? String
    @alias = nil
    path_part = node_data
  else
    raise Onde::ConfigurationError.new("Node #{data} is not properly formed")
  end
  
  @path = parent_path.nil? ? path_part : File.join(parent_path, path_part)
  
  child_data ||= []
  @children = child_data.map do |child_data|
    Onde::Node.new(child_data, @path)
  end
end