aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/version.rb
diff options
context:
space:
mode:
authorJack Nagel2013-02-06 22:25:02 -0600
committerJack Nagel2013-02-06 22:25:02 -0600
commit15562c8876f5ad8acbe8a73516e60e3bdda3c3af (patch)
tree873cea75a7f83af220df5769d0d9d77bbcf7a697 /Library/Homebrew/version.rb
parent7178210a71be41eb56dd238b57a6e77c29cccbf6 (diff)
downloadbrew-15562c8876f5ad8acbe8a73516e60e3bdda3c3af.tar.bz2
Version: kill silly class method
Overriding <=> directly is much simpler.
Diffstat (limited to 'Library/Homebrew/version.rb')
-rw-r--r--Library/Homebrew/version.rb24
1 files changed, 9 insertions, 15 deletions
diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb
index 982c83bfe..eaf201a08 100644
--- a/Library/Homebrew/version.rb
+++ b/Library/Homebrew/version.rb
@@ -188,13 +188,6 @@ class Version
m = /\.v(\d+[a-z]?)/.match(stem)
return m.captures.first unless m.nil?
end
-
- # DSL for defining comparators
- class << self
- def compare &blk
- send(:define_method, '<=>', &blk)
- end
- end
end
class VersionSchemeDetector
@@ -220,13 +213,14 @@ end
# Enable things like "MacOS.version >= :lion"
class MacOSVersion < Version
- compare do |other|
- super Version.new case other
- when :mountain_lion then 10.8
- when :lion then 10.7
- when :snow_leopard then 10.6
- when :leopard then 10.5
- else other.to_s
- end
+ def <=>(other)
+ v = case other
+ when :mountain_lion then 10.8
+ when :lion then 10.7
+ when :snow_leopard then 10.6
+ when :leopard then 10.5
+ else other.to_s
+ end
+ super(Version.new(v))
end
end