Checking what OS Ruby is running on
If for any reason you need to what operating system Ruby is running on, checking RUBY_PLATFORM
might not be what you need. Why not? Because JRuby runs on several platforms, but RUBY_PLATFORM
will return 'java' no matter what the host OS is.
Instead, use RbConfig:
require "rbconfig"
if RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
# do something
end
Written by Norman Clarke
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#