Add MacOS::Version.from_symbol
This commit is contained in:
parent
cf66686a17
commit
3cd1a0e696
@ -2,15 +2,21 @@ require 'version'
|
|||||||
|
|
||||||
module MacOS
|
module MacOS
|
||||||
class Version < ::Version
|
class Version < ::Version
|
||||||
|
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
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
v = case other
|
v = SYMBOLS.fetch(other, other.to_s)
|
||||||
when :mountain_lion then "10.8"
|
|
||||||
when :lion then "10.7"
|
|
||||||
when :snow_leopard then "10.6"
|
|
||||||
when :leopard then "10.5"
|
|
||||||
when :tiger then "10.4"
|
|
||||||
else other.to_s
|
|
||||||
end
|
|
||||||
super(Version.new(v))
|
super(Version.new(v))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user