[ruby-it] File.basename("xxx", "x*x") l'asterisco funziona?
Alessandro Scolavino
scolas a gmail.com
Gio 25 Mar 2010 11:38:07 CET
le api di ruby dicono:
Returns the last component of the filename given in file_name, which
must be formed using forward slashes (``/’’) regardless of the separator
used on the local file system. If suffix is given and present at the end
of file_name, it is removed.
File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
puoi postare come sono i nomi file e cosa c'č nel file @ file ?
per altro cosė a occhio (immagino tu usi linux) se usi il comando ls
"#{@percorso2}"*.dar ti restituisce l'elenco file senza il path quindi
fare basename non ti serve puoi fare direttamente
filename2.gsub('.1.dar', '') o una regex per togliere qualunque
carattere al posto di 1 ... (che č quasi la stessa cosa che fare
basename con il parametro estensione)
--
Posted via http://www.ruby-forum.com/.
More information about the Ml
mailing list