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
|
2013-06-14 11:56:33 -07:00
|
|
|
|
2013-06-15 19:40:42 -05:00
|
|
|
def to_sym
|
2013-06-14 14:47:16 -07:00
|
|
|
case @version
|
2013-06-15 19:40:42 -05:00
|
|
|
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 :dunno
|
2013-06-14 14:47:16 -07:00
|
|
|
end
|
2013-06-14 11:56:33 -07:00
|
|
|
end
|
2013-06-15 19:40:42 -05:00
|
|
|
|
|
|
|
def pretty_name
|
|
|
|
to_sym.to_s.split('_').map(&:capitalize).join(' ')
|
|
|
|
end
|
2013-02-06 22:49:43 -06:00
|
|
|
end
|
|
|
|
end
|