class Onde::DirectoryStructure

Public Class Methods

new(data) click to toggle source
# File lib/onde.rb, line 68
def initialize(data)
  @expanded_paths = {}
  data.map do |node_data|
    node = Onde::Node.new(node_data)
    expand_node(node)
  end
end
paths(data) click to toggle source
# File lib/onde.rb, line 64
def self.paths(data)
  self.new(data).to_hash
end

Public Instance Methods

to_hash() click to toggle source
# File lib/onde.rb, line 76
def to_hash
  @expanded_paths
end

Private Instance Methods

expand_node(node) click to toggle source
# File lib/onde.rb, line 80
        def expand_node(node)
  if node.alias
    node_alias = node.alias.to_sym
    if @expanded_paths[node_alias]
      raise Onde::ConfigurationError.new('More than one path is tagged with the same alias.') 
    end
    @expanded_paths[node_alias] = node.path
  end

  node.children.each do |child_node|
    expand_node(child_node)
  end
end