Method: TTY::Tree::PathWalker#initialize

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

#initialize(options = {}) ⇒ PathWalker

Create a PathWalker



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tty/tree/path_walker.rb', line 22

def initialize(options = {})
  @files_count = 0
  @dirs_count  = 0
  @nodes       = []
  @filters     = []
  @level       = options.fetch(:level) { -1 }
  @file_limit  = options.fetch(:file_limit) { - 1 }

  unless options[:show_hidden]
    add_filter(-> (p) { !p.basename.to_s.start_with?('.') })
  end

  if options[:only_dirs]
    add_filter(-> (p) { p.directory? })
  end
end