os/mac/version: update method signatures
This commit is contained in:
parent
2268e774a4
commit
779f2fc6ef
@ -13,6 +13,7 @@ module OS
|
|||||||
class Version < ::Version
|
class Version < ::Version
|
||||||
extend T::Sig
|
extend T::Sig
|
||||||
|
|
||||||
|
sig { returns(Symbol) }
|
||||||
attr_reader :arch
|
attr_reader :arch
|
||||||
|
|
||||||
SYMBOLS = {
|
SYMBOLS = {
|
||||||
@ -33,7 +34,7 @@ module OS
|
|||||||
new(str, arch: arch)
|
new(str, arch: arch)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(value: T.any(String, Symbol)).returns(T::Array[String]) }
|
sig { params(value: T.any(String, Symbol)).returns(T.any([], [String, T.nilable(String)])) }
|
||||||
def self.version_arch(value)
|
def self.version_arch(value)
|
||||||
@all_archs_regex ||= begin
|
@all_archs_regex ||= begin
|
||||||
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
|
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
|
||||||
@ -43,7 +44,7 @@ module OS
|
|||||||
(-(?<suffix_arch>#{Regexp.union(all_archs)}))?$
|
(-(?<suffix_arch>#{Regexp.union(all_archs)}))?$
|
||||||
/x
|
/x
|
||||||
end
|
end
|
||||||
match = @all_archs_regex.match(value)
|
match = @all_archs_regex.match(value.to_s)
|
||||||
return [] unless match
|
return [] unless match
|
||||||
|
|
||||||
version = match[:version]
|
version = match[:version]
|
||||||
@ -65,6 +66,7 @@ module OS
|
|||||||
@comparison_cache = {}
|
@comparison_cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
@comparison_cache.fetch(other) do
|
@comparison_cache.fetch(other) do
|
||||||
if SYMBOLS.key?(other) && to_sym == other
|
if SYMBOLS.key?(other) && to_sym == other
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user