Class: Tree
- Inherits:
-
Object
- Object
- Tree
- Defined in:
- lib/tree.rb
Overview
Tree class create array of all root directories
Instance Attribute Summary collapse
-
#directories ⇒ Object
readonly
Returns the value of attribute directories.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#path_array ⇒ Object
readonly
Returns the value of attribute path_array.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#tree_data ⇒ Object
readonly
Returns the value of attribute tree_data.
Instance Method Summary collapse
-
#initialize(path = Dir.pwd) ⇒ Tree
constructor
A new instance of Tree.
- #run ⇒ Object
- #run_results ⇒ Object
Constructor Details
#initialize(path = Dir.pwd) ⇒ Tree
Returns a new instance of Tree.
15 16 17 18 19 20 21 |
# File 'lib/tree.rb', line 15 def initialize(path = Dir.pwd) @root = path @directories = 0 @files = 0 @tree_data = [] @path_array = [] end |
Instance Attribute Details
#directories ⇒ Object (readonly)
Returns the value of attribute directories.
9 10 11 |
# File 'lib/tree.rb', line 9 def directories @directories end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
9 10 11 |
# File 'lib/tree.rb', line 9 def files @files end |
#path_array ⇒ Object (readonly)
Returns the value of attribute path_array.
9 10 11 |
# File 'lib/tree.rb', line 9 def path_array @path_array end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
9 10 11 |
# File 'lib/tree.rb', line 9 def root @root end |
#tree_data ⇒ Object (readonly)
Returns the value of attribute tree_data.
9 10 11 |
# File 'lib/tree.rb', line 9 def tree_data @tree_data end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/tree.rb', line 23 def run @root = Pathname.new(@root) @root.each_child do |dir| @path_array << dir @tree_data << dir end end |
#run_results ⇒ Object
31 32 33 |
# File 'lib/tree.rb', line 31 def run_results [@path_array, @directories, @files, @tree_data, @root] end |