brew/Library/Homebrew/os/mac/version.rb

36 lines
737 B
Ruby
Raw Normal View History

2013-02-06 22:49:43 -06:00
require 'version'
module MacOS
class Version < ::Version
2013-06-15 19:39:27 -05:00
SYMBOLS = {
:mavericks => '10.9',
:mountain_lion => '10.8',
:lion => '10.7',
:snow_leopard => '10.6',
:leopard => '10.5',
:tiger => '10.4',
}
def self.from_symbol(sym)
new(SYMBOLS.fetch(sym))
end
2013-02-06 22:49:43 -06:00
def <=>(other)
2013-06-15 19:39:27 -05:00
v = SYMBOLS.fetch(other, other.to_s)
2013-02-06 22:49:43 -06:00
super(Version.new(v))
end
def pretty_name
2013-06-14 14:47:16 -07:00
case @version
when "10.9" then "Mavericks"
when "10.8" then "Mountain Lion"
when "10.7" then "Lion"
when "10.6" then "Snow Leopard"
when "10.5" then "Leopard"
when "10.4" then "Tiger"
else @version
end
end
2013-02-06 22:49:43 -06:00
end
end