os/mac/version: add strip_patch method

This commit is contained in:
Bo Anderson 2021-02-09 18:34:47 +00:00
parent 71d81a8611
commit 61cda1465f

View File

@ -78,17 +78,19 @@ module OS
end
end
sig { returns(T.self_type) }
def strip_patch
# Big Sur is 11.x but Catalina is 10.15.x.
if major >= 11
self.class.new(major.to_s)
else
major_minor
end
end
sig { returns(Symbol) }
def to_sym
@to_sym ||= begin
# Big Sur is 11.x but Catalina is 10.15.
major_macos = if major >= 11
major
else
major_minor
end.to_s
SYMBOLS.invert.fetch(major_macos, :dunno)
end
@to_sym ||= SYMBOLS.invert.fetch(strip_patch.to_s, :dunno)
end
sig { returns(String) }