Skip to content

Instantly share code, notes, and snippets.

@JoeyBurzynski
Created May 1, 2016 19:38
Show Gist options
  • Save JoeyBurzynski/44d74533265ab85a14917897c1effc7b to your computer and use it in GitHub Desktop.
Save JoeyBurzynski/44d74533265ab85a14917897c1effc7b to your computer and use it in GitHub Desktop.
Ruby: Determine Operating System
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.unix?
!OS.windows?
end
def OS.linux?
OS.unix? and not OS.mac?
end
end
puts OS.windows?
puts OS.mac?
puts OS.unix?
puts OS.linux?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment