2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-03 16:28:16 -07:00
|
|
|
class Version
|
2020-08-09 02:59:18 +02:00
|
|
|
# Represents the absence of a version.
|
2016-11-03 16:28:16 -07:00
|
|
|
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
|
|
|
|
|
2019-08-19 14:27:29 +10:00
|
|
|
# For OS::Mac::Version compatibility
|
2019-01-28 19:31:21 +00:00
|
|
|
def requires_nehalem_cpu?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
alias_method :requires_sse4?, :requires_nehalem_cpu?
|
|
|
|
alias_method :requires_sse41?, :requires_nehalem_cpu?
|
|
|
|
alias_method :requires_sse42?, :requires_nehalem_cpu?
|
|
|
|
alias_method :requires_popcnt?, :requires_nehalem_cpu?
|
|
|
|
|
2020-08-11 13:01:10 -07:00
|
|
|
def major
|
|
|
|
NULL_TOKEN
|
|
|
|
end
|
|
|
|
|
|
|
|
def minor
|
|
|
|
NULL_TOKEN
|
|
|
|
end
|
|
|
|
|
|
|
|
def patch
|
|
|
|
NULL_TOKEN
|
|
|
|
end
|
|
|
|
|
|
|
|
def major_minor
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def major_minor_patch
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2016-11-03 16:28:16 -07:00
|
|
|
def to_f
|
|
|
|
Float::NAN
|
|
|
|
end
|
|
|
|
|
2017-11-30 09:42:14 +00:00
|
|
|
def to_i
|
|
|
|
0
|
|
|
|
end
|
|
|
|
|
2016-11-03 16:28:16 -07:00
|
|
|
def to_s
|
|
|
|
""
|
|
|
|
end
|
|
|
|
alias_method :to_str, :to_s
|
2016-11-21 08:48:26 +00:00
|
|
|
|
|
|
|
def inspect
|
2019-04-19 15:38:03 +09:00
|
|
|
"#<Version::NULL>"
|
2016-11-21 08:48:26 +00:00
|
|
|
end
|
2019-04-19 21:46:20 +09:00
|
|
|
end.new.freeze
|
2016-11-03 16:28:16 -07:00
|
|
|
end
|