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 # >> # # >> \- # # >> \- # # >> | \- # # >> | | \- # # >> | \- # # >> | | \- # # >> \- # # >> | \- # # >> \- # # >> | \- #