Class: PkgVersion Private
- Inherits:
-
Object
- Object
- PkgVersion
- 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
- #revision ⇒ Object readonly private
- #version ⇒ Object readonly private
Class Method Summary collapse
- .parse(path) ⇒ Object private
Instance Method Summary collapse
- #<=>(other) ⇒ Object private
- #hash ⇒ Object private
- #head? ⇒ Boolean private
-
#initialize(version, revision) ⇒ PkgVersion
constructor
private
A new instance of PkgVersion.
- #to_s ⇒ Object (also: #to_str) private
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.
26 27 28 29 |
# File 'Library/Homebrew/pkg_version.rb', line 26 def initialize(version, revision) @version = version @revision = revision end |
Instance Attribute Details
#revision ⇒ Object (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.
16 17 18 |
# File 'Library/Homebrew/pkg_version.rb', line 16 def revision @revision end |
#version ⇒ Object (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.
16 17 18 |
# File 'Library/Homebrew/pkg_version.rb', line 16 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.
20 21 22 23 24 |
# File 'Library/Homebrew/pkg_version.rb', line 20 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.
44 45 46 47 48 49 50 51 |
# File 'Library/Homebrew/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 |
#hash ⇒ 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.
54 55 56 |
# File 'Library/Homebrew/pkg_version.rb', line 54 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.
31 32 33 |
# File 'Library/Homebrew/pkg_version.rb', line 31 def head? version.head? end |
#to_s ⇒ Object 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.
35 36 37 38 39 40 41 |
# File 'Library/Homebrew/pkg_version.rb', line 35 def to_s if revision.positive? "#{version}_#{revision}" else version.to_s end end |