# FileTree A simple tree structure for working with FilePath objects in ruby. I simply took the simple_tree module from https://github.com/ealdent/simple-tree and hacked it into [Pathname](http://www.ruby-doc.org/stdlib-2.0/libdoc/pathname/rdoc/Pathname.html) from the std-lib. This means you get all the awesome features of working with Pathname, as well as making it easy to examine a filepath's ancestors and descendants. ## Install install with: `gem install filetree` # Usage ```ruby require "filetree" tree = FileTree.new('/home/user/test/test1/test2') # => # tree.parent # => # tree.ancestors # => [#, # #, # #, # #] tree.descendants # => [#, # #, # #, # #, # #, # #, # #, # #, # #, # #] des_arr = tree.descendants.map { |e| FileTree.new(e.relative_path_from(FileTree.new('/home/user'))) } # => [#, # #, # #, # #, # #, # #, # #, # #, # #, # #] des_arr.first # => # des_arr.last.ancestors # infinite loop. "ancestors" depends on hitting "/" to stop. # the "tree_rep" method provides prettyprinting for creating your own to_s methods puts tree.tree_rep # => nil # >> # # >> \- # # >> \- # # >> | \- # # >> | | \- # # >> | \- # # >> | | \- # # >> \- # # >> | \- # # >> \- # # >> | \- # ``` # Credits All credit belongs to the following persons, I just cobbled this together from their work: - [@ealdent](https://github.com/ealdent/simple-tree) - The authors and maintainers of [Pathname](http://www.ruby-doc.org/stdlib-2.0/libdoc/pathname/rdoc/Pathname.html) # License Distributed under the BSD license, please see [LICENSE](https://github.com/edubkendo/FileTree/blob/master/LICENSE) for more information.