Class: ACLS::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/acls/tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, name, directory, source = nil) ⇒ Tree



5
6
7
8
9
10
11
# File 'lib/acls/tree.rb', line 5

def initialize(parent, name, directory, source=nil)
  @parent = parent
  @name = name
  @directory = directory
  @source = source
  @children = []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



3
4
5
# File 'lib/acls/tree.rb', line 3

def children
  @children
end

#directoryObject

Returns the value of attribute directory.



3
4
5
# File 'lib/acls/tree.rb', line 3

def directory
  @directory
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/acls/tree.rb', line 3

def name
  @name
end

#parentObject

Returns the value of attribute parent.



3
4
5
# File 'lib/acls/tree.rb', line 3

def parent
  @parent
end

#sourceObject

Returns the value of attribute source.



3
4
5
# File 'lib/acls/tree.rb', line 3

def source
  @source
end

Instance Method Details

#make_child(name, directory, source = nil) ⇒ Object



13
14
15
16
17
# 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

#pathObject



19
20
21
# File 'lib/acls/tree.rb', line 19

def path
  @source || @directory
end

#to_sObject



23
24
25
# File 'lib/acls/tree.rb', line 23

def to_s
  "name: #{@name}, source: #{@source}, directory: #{@directory}, parent: #{@parent}, children: #{@children.length}"
end