Class: OS::Mac::Version

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

Constant Summary collapse

SYMBOLS =
{
  high_sierra: "10.13",
  sierra: "10.12",
  el_capitan: "10.11",
  yosemite: "10.10",
  mavericks: "10.9",
  mountain_lion: "10.8",
  lion: "10.7",
  snow_leopard: "10.6",
  leopard_64: "10.5",
  leopard: "10.5",
  tiger: "10.4",
}.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?, #hash, #head?, #null?, parse, #to_f, #to_i, #to_s

Constructor Details

#initialize(*args) ⇒ Version

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



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

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



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



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

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

#to_symObject



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

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