The Operating System
This chapter covers practical topic: working with the Operating System. Working with files, file permissions, running the programs and getting the results, dealing with
stdout and so on.
Files on Windows
All examples are working under Unix-like Operating Systems and most of them should work in Windows as well. Notice that Ruby shows the file path using slash regardless on which OS it is running.
Dir.pwd #=> "C:/Ruby200/bin" File.exists?("c:/windows/system32/drivers/etc/hosts") #=> true
It is good to use the combinations of the methods
File::join to ensure that your code is not dependent on the OS:
File.join(Dir.pwd, "ruby.exe") #=> "C:/Ruby200/bin/ruby.exe"