Class: OS::Mac::Version Private

Inherits:
Version show all
Defined in:
Library/Homebrew/os/mac/version.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A macOS version.

Constant Summary collapse

SYMBOLS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  big_sur:     "11.0",
  catalina:    "10.15",
  mojave:      "10.14",
  high_sierra: "10.13",
  sierra:      "10.12",
  el_capitan:  "10.11",
  yosemite:    "10.10",
}.freeze

Constants inherited from Version

Version::NULL, Version::NULL_TOKEN

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Version

create, detect, #detected_from_url?, #empty?, formula_optionally_versioned_regex, #hash, #head?, #major, #major_minor, #major_minor_patch, #minor, #null?, parse, #patch, #to_f, #to_i, #to_s

Constructor Details

#initialize(*args) ⇒ Version

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Version.


27
28
29
30
# File 'Library/Homebrew/os/mac/version.rb', line 27

def initialize(*args)
  super
  @comparison_cache = {}
end

Class Method Details

.from_symbol(sym) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


22
23
24
25
# File 'Library/Homebrew/os/mac/version.rb', line 22

def self.from_symbol(sym)
  str = SYMBOLS.fetch(sym) { raise MacOSVersionError, sym }
  new(str)
end

Instance Method Details

#<=>(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


32
33
34
35
36
37
# File 'Library/Homebrew/os/mac/version.rb', line 32

def <=>(other)
  @comparison_cache.fetch(other) do
    v = SYMBOLS.fetch(other) { other.to_s }
    @comparison_cache[other] = super(Version.new(v))
  end
end

#pretty_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


43
44
45
# File 'Library/Homebrew/os/mac/version.rb', line 43

def pretty_name
  to_sym.to_s.split("_").map(&:capitalize).join(" ")
end

#requires_nehalem_cpu?Boolean Also known as: requires_sse4?, requires_sse41?, requires_sse42?, requires_popcnt?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

For OS::Mac::Version compatibility

Returns:

  • (Boolean)

48
49
50
51
52
53
54
# File 'Library/Homebrew/os/mac/version.rb', line 48

def requires_nehalem_cpu?
  unless Hardware::CPU.intel?
    raise "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture."
  end

  Hardware.oldest_cpu(self) == :nehalem
end

#to_symObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


39
40
41
# File 'Library/Homebrew/os/mac/version.rb', line 39

def to_sym
  SYMBOLS.invert.fetch(@version, :dunno)
end