class ACLS::Tree

Attributes

children[RW]
directory[RW]
name[RW]
parent[RW]
source[RW]

Public Class Methods

new(parent, name, directory, source=nil) click to toggle source
# File lib/acls/tree.rb, line 5
def initialize(parent, name, directory, source=nil)
  @parent = parent
  @name = name
  @directory = directory
  @source = source
  @children = []
end

Public Instance Methods

find(name) click to toggle source

Find the first child with a given name, including the calling node in the search.

# File lib/acls/tree.rb, line 26
def find(name)
  return self if @name == name
  @children.find { |child| child.find(name) }
end
make_child(name, directory, source=nil) click to toggle source
# File lib/acls/tree.rb, line 13
def make_child(name, directory, source=nil)
  child = Tree.new(self, name, directory, source)
  @children << child
  child
end
path() click to toggle source

If a source file is specified, returns the path to the source file.

# File lib/acls/tree.rb, line 20
def path
  @source || @directory
end
to_s(level=0) click to toggle source
# File lib/acls/tree.rb, line 31
    def to_s(level=0)
      tab = '**' * 2 * level
      <<EOS
#{tab}     level: #{level}
#{tab}      name: #{@name}
#{tab}    source: #{@source}
#{tab} directory: #{@directory}
#{tab}  children => [
#{@children.map { |child| child.to_s(level+1) }.join}
#{tab}  ]
EOS
    end