Created
December 19, 2011 14:34
-
-
Save knicklabs/1497473 to your computer and use it in GitHub Desktop.
How to get the type of operating system in a ruby script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rbconfig' | |
host_os = RbConfig::CONFIG['host_os'] | |
if host_os ~= /mac|darwin/i | |
# Mac | |
elsif host_os ~= /bsd/i | |
# BSD | |
elsif host_os ~= /solaris|sunos/i | |
# Solaris | |
elsif host_os ~= /linux/i | |
# Linux | |
elsif host_os ~= /mswin|windows|cygwin/i | |
# Windows | |
else | |
# Any platform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment