title: Ruby FTP Separating files from Folders
body: <p>I'm trying to crawl FTP and pull down all the files recursively. </p>
  
  <p>Up until now I was trying to pull down a directory with </p>
  
  <pre><code>   ftp.list.each do |entry|
      if entry.split(/\s+/)[0][0, 1] == "d"
        out[:dirs] &lt;&lt; entry.split.last unless black_dirs.include? entry.split.last
      else
        out[:files] &lt;&lt; entry.split.last unless black_files.include? entry.split.last
      end
  </code></pre>
  
  <p>But turns out, if you split the list up until last space, filenames and directories with spaces are fetched wrong.
  Need a little help on the logic here.</p>