From 9bac107b31f05cca65d8aab23be05e1b867bd289 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Thu, 3 Nov 2016 16:28:16 -0700 Subject: Add Version::NULL singleton --- Library/Homebrew/version/null.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Library/Homebrew/version/null.rb (limited to 'Library/Homebrew/version') 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 -- cgit v1.2.3