Detecting Operating Systems in Ruby [duplicate]

You can use the os gem:

gem install os

And then

require 'os'
OS.linux?   #=> true or false
OS.windows? #=> true or false
OS.java?    #=> true or false
OS.bsd?     #=> true or false
OS.mac?     #=> true or false
# and so on.

See: https://github.com/rdp/os

Leave a Comment