Add small DSL for defining comparators

This commit is contained in:
Jack Nagel 2012-08-14 12:16:52 -05:00
parent 93baea7e47
commit 158b7047e5

View File

@ -125,6 +125,13 @@ class Version
m = /_([^_]+)/.match(stem) m = /_([^_]+)/.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