Method: TTY::Tree::PathWalker#traverse

Defined in:
lib/tty/tree/path_walker.rb

#traverse(path) ⇒ Object

Traverse given path recursively

Parameters:

  • path (String)

    the path to traverse



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/tty/tree/path_walker.rb', line 49

def traverse(path)
  root_path  = Pathname.new(path)
  empty_path = Pathname.new('')

  unless root_path.directory?
    raise ArgumentError, "#{root_path} is not a directory path"
  end

  @nodes << Node.new(root_path, empty_path, '', 0)

  walk(root_path, root_path.children, '', 1)
end