This website uses cookies. If you continue to use this site we will assume that you are happy with this. When you close this box we will save this information in a cookie to ensure you'll never be bothered with this information box. ×

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 stdin and 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.

#=> "C:/Ruby200/bin"

#=> true

It is good to use the combinations of the methods Dir::pwd and File::join to ensure that your code is not dependent on the OS:

File.join(Dir.pwd, "ruby.exe")
#=> "C:/Ruby200/bin/ruby.exe"