aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/version
diff options
context:
space:
mode:
authorMisty De Meo2016-11-14 13:44:03 -0800
committerGitHub2016-11-14 13:44:03 -0800
commit30fdbe089b6a7d91dd12132b46436f90dad60c88 (patch)
treee6795dfbc3549722dfb536d5c1503776ea5e0d0d /Library/Homebrew/version
parent3a01fbadcd14fb180635d6464f2c600a738d50b5 (diff)
parentc7be025229dbbe86d85982a135c75b04c9ba00f2 (diff)
downloadbrew-30fdbe089b6a7d91dd12132b46436f90dad60c88.tar.bz2
Merge pull request #1435 from mistydemeo/dev_tools_version
Add "null version" class, and return compiler versions/build versions as Version objects
Diffstat (limited to 'Library/Homebrew/version')
-rw-r--r--Library/Homebrew/version/null.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/Library/Homebrew/version/null.rb b/Library/Homebrew/version/null.rb
new file mode 100644
index 000000000..77106bcce
--- /dev/null
+++ b/Library/Homebrew/version/null.rb
@@ -0,0 +1,38 @@
+class Version
+ NULL = Class.new do
+ include Comparable
+
+ def <=>(_other)
+ -1
+ end
+
+ def eql?(_other)
+ # Makes sure that the same instance of Version::NULL
+ # will never equal itself; normally Comparable#==
+ # will return true for this regardless of the return
+ # value of #<=>
+ false
+ end
+
+ def detected_from_url?
+ false
+ end
+
+ def head?
+ false
+ end
+
+ def null?
+ true
+ end
+
+ def to_f
+ Float::NAN
+ end
+
+ def to_s
+ ""
+ end
+ alias_method :to_str, :to_s
+ end.new
+end