Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created August 2, 2008 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommorris/3736 to your computer and use it in GitHub Desktop.
Save tommorris/3736 to your computer and use it in GitHub Desktop.
detects OS versions
class OsVersion
attr_reader :ruby_platform, :os, :ident, :version, :build
def initialize
@ruby_platform = RUBY_PLATFORM
if File.exists?("/proc/version")
@os = :linux
@ident = File.open("/proc/version").readlines.join
elsif `sw_vers`.length != 0
@os = :macosx
@version = `sw_vers -productVersion`.chop!
@build = `sw_vers -buildVersion`
elsif @ruby_platform =~ /(win|w)32$/
@os = :windows
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment