How get filename from FTP::list

The following code displays the file’s date, time size and name. How can
I access just the file’s name from within the block?

@@ftp.list(file_template) do |f|
  puts f.name
end

Thanks.

Bazsl wrote:

The following code displays the file’s date, time size and name. How
can I access just the file’s name from within the block?

@@ftp.list(file_template) do |f|
puts f.name
end

Thanks.

You can use Net:FTP#nlist[1] if you don’t need to filter them.
Otherwise I suppose you could do something like:

@@ftp.list(file_template) do |f|
puts f.match(/:\d\d\s(.*)$/)[1]
end

Which works for me. I have no idea if FTP servers vary in their ls
output.

-Justin

[1]http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/classes/Net/FTP.html#M001055