Class: OS::Mac::Version

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

Constant Summary collapse

SYMBOLS =
{
  catalina:    "10.15",
  mojave:      "10.14",
  high_sierra: "10.13",
  sierra:      "10.12",
  el_capitan:  "10.11",
  yosemite:    "10.10",
  mavericks:   "10.9",
}.freeze

Constants inherited from Version

Version::NULL, Version::NULL_TOKEN, Version::SCAN_PATTERN

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Version

create, detect, #detected_from_url?, formula_optionally_versioned_regex, #hash, #head?, #null?, parse, #to_f, #to_i, #to_s

Constructor Details

#initialize(*args) ⇒ Version

Returns a new instance of Version



25
26
27
28
# File 'brew/Library/Homebrew/os/mac/version.rb', line 25

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

Class Method Details

.from_symbol(sym) ⇒ Object



18
19
20
21
22
23
# File 'brew/Library/Homebrew/os/mac/version.rb', line 18

def self.from_symbol(sym)
  str = SYMBOLS.fetch(sym) do
    raise ArgumentError, "unknown version #{sym.inspect}"
  end
  new(str)
end

Instance Method Details

#<=>(other) ⇒ Object



30
31
32
33
34
35
# File 'brew/Library/Homebrew/os/mac/version.rb', line 30

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



41
42
43
# File 'brew/Library/Homebrew/os/mac/version.rb', line 41

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?

For OS::Mac::Version compatability

Returns:

  • (Boolean)


46
47
48
# File 'brew/Library/Homebrew/os/mac/version.rb', line 46

def requires_nehalem_cpu?
  Hardware.oldest_cpu(self) == :nehalem
end

#to_symObject



37
38
39
# File 'brew/Library/Homebrew/os/mac/version.rb', line 37

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