Method: Net::FTP#walk

Defined in:
lib/net/ftp/walk.rb

#walk(dir, parser_class = Net::FTP::List, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/net/ftp/walk.rb', line 4

def walk(dir, parser_class = Net::FTP::List, &block)
  paths = [ dir ]

  while paths.count > 0 do
    path = paths.pop

    self.list(path) do |e|
      entry = parser_class.parse(e)

      if entry.dir? then
        unless ['.', '..'].include? entry.basename then
          paths << path + '/' + entry.basename
        end
      else
        yield path, entry
      end
    end
  end
end