Version: kill silly class method
Overriding <=> directly is much simpler.
This commit is contained in:
parent
7178210a71
commit
15562c8876
@ -188,13 +188,6 @@ class Version
|
|||||||
m = /\.v(\d+[a-z]?)/.match(stem)
|
m = /\.v(\d+[a-z]?)/.match(stem)
|
||||||
return m.captures.first unless m.nil?
|
return m.captures.first unless m.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
# DSL for defining comparators
|
|
||||||
class << self
|
|
||||||
def compare &blk
|
|
||||||
send(:define_method, '<=>', &blk)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class VersionSchemeDetector
|
class VersionSchemeDetector
|
||||||
@ -220,13 +213,14 @@ end
|
|||||||
|
|
||||||
# Enable things like "MacOS.version >= :lion"
|
# Enable things like "MacOS.version >= :lion"
|
||||||
class MacOSVersion < Version
|
class MacOSVersion < Version
|
||||||
compare do |other|
|
def <=>(other)
|
||||||
super Version.new case other
|
v = case other
|
||||||
when :mountain_lion then 10.8
|
when :mountain_lion then 10.8
|
||||||
when :lion then 10.7
|
when :lion then 10.7
|
||||||
when :snow_leopard then 10.6
|
when :snow_leopard then 10.6
|
||||||
when :leopard then 10.5
|
when :leopard then 10.5
|
||||||
else other.to_s
|
else other.to_s
|
||||||
end
|
end
|
||||||
|
super(Version.new(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user