Yohanes Santoso
7/11/2006 2:49:00 PM
"Minkoo Seo" <minkoo.seo@gmail.com> writes:
> Hi list.
>
> I'd like to ask a question on platform independent programming with Ruby.
> The very first thing that comes to my mind is "\r\n" (new line) and "\"
> (directory
> separator).
Use "\n" and File::SEPARATOR (alternatively, if you care about unix
and windows only (osx counts as unix), "/" is acceptable)
"\n" would map to "\r\n" for text files in windows, and "\r" for text
files in mac os 9. In Unix, it stays as-is.
YS.
> print "Hello\r\n"
print "Hello\n"
> Dir["/tmp/*"]
That works in windows & unix. You can also do: Dir[File.join(*%w{/tmp
*})]. (Note the symbol / for root directory or the concept of root
directory is not universal, thus why the "/tmp").
YS.