Class: PkgVersion Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Comparable
Defined in:
Library/Homebrew/pkg_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.

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. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PkgVersion.


25
26
27
28
# File 'Library/Homebrew/pkg_version.rb', line 25

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

Instance Attribute Details

#revisionObject (readonly)

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.


15
16
17
# File 'Library/Homebrew/pkg_version.rb', line 15

def revision
  @revision
end

#versionObject (readonly)

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.


15
16
17
# File 'Library/Homebrew/pkg_version.rb', line 15

def version
  @version
end

Class Method Details

.parse(path) ⇒ 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.


19
20
21
22
23
# File 'Library/Homebrew/pkg_version.rb', line 19

def self.parse(path)
  _, version, revision = *path.match(REGEX)
  version = Version.create(version)
  new(version, revision.to_i)
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.


43
44
45
46
47
48
49
50
# File 'Library/Homebrew/pkg_version.rb', line 43

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. You should avoid using this method if possible, as it may be removed or be changed in the future.


53
54
55
# File 'Library/Homebrew/pkg_version.rb', line 53

def hash
  version.hash ^ revision.hash
end

#head?Boolean

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:

  • (Boolean)

30
31
32
# File 'Library/Homebrew/pkg_version.rb', line 30

def head?
  version.head?
end

#to_sObject Also known as: to_str

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.


34
35
36
37
38
39
40
# File 'Library/Homebrew/pkg_version.rb', line 34

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