Class: PkgVersion Private

Inherits:
Object show all
Extended by:
Forwardable
Includes:
Comparable
Defined in:
pkg_version.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Combination of a version and a revision.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, revision) ⇒ PkgVersion

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns a new instance of PkgVersion.



26
27
28
29
# File 'pkg_version.rb', line 26

def initialize(version, revision)
  @version = version
  @revision = revision
end

Instance Attribute Details

#revisionObject (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



16
17
18
# File 'pkg_version.rb', line 16

def revision
  @revision
end

#versionObject (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



16
17
18
# File 'pkg_version.rb', line 16

def version
  @version
end

Class Method Details

.parse(path) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



20
21
22
23
24
# File 'pkg_version.rb', line 20

def self.parse(path)
  _, version, revision = *path.match(REGEX)
  version = Version.new(version)
  new(version, revision.to_i)
end

Instance Method Details

#<=>(other) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



44
45
46
47
48
49
50
51
# File 'pkg_version.rb', line 44

def <=>(other)
  return unless other.is_a?(PkgVersion)

  version_comparison = (version <=> other.version)
  return if version_comparison.nil?

  version_comparison.nonzero? || revision <=> other.revision
end

#hashObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



54
55
56
# File 'pkg_version.rb', line 54

def hash
  [version, revision].hash
end

#head?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


31
32
33
# File 'pkg_version.rb', line 31

def head?
  version.head?
end

#to_sObject Also known as: to_str

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



35
36
37
38
39
40
41
# File 'pkg_version.rb', line 35

def to_s
  if revision.positive?
    "#{version}_#{revision}"
  else
    version.to_s
  end
end