Class: Homebrew::Livecheck::LivecheckVersion Private
- Includes:
- Comparable
- Defined in:
- livecheck/livecheck_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.
A formula or cask version, split into its component sub-versions.
Instance Attribute Summary collapse
-
#versions ⇒ Array<Version>
readonly
private
Class Method Summary collapse
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer?
private
-
#initialize(versions) ⇒ void
constructor
private
Constructor Details
#initialize(versions) ⇒ void
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.
31 32 33 |
# File 'livecheck/livecheck_version.rb', line 31 def initialize(versions) @versions = versions end |
Instance Attribute Details
#versions ⇒ Array<Version> (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.
28 29 30 |
# File 'livecheck/livecheck_version.rb', line 28 def versions @versions end |
Class Method Details
.create(package_or_resource, version) ⇒ LivecheckVersion
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.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'livecheck/livecheck_version.rb', line 15 def self.create(package_or_resource, version) versions = case package_or_resource when Formula, Resource [version] when Cask::Cask version.to_s.split(",").map { |s| Version.new(s) } else T.absurd(package_or_resource) end new(versions) end |
Instance Method Details
#<=>(other) ⇒ Integer?
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.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'livecheck/livecheck_version.rb', line 36 def <=>(other) return unless other.is_a?(LivecheckVersion) lversions = versions rversions = other.versions max = [lversions.count, rversions.count].max l = r = 0 while l < max a = lversions[l] || Version::NULL b = rversions[r] || Version::NULL if a == b l += 1 r += 1 next elsif !a.null? && b.null? return 1 if a > Version::NULL l += 1 elsif a.null? && !b.null? return -1 if b > Version::NULL r += 1 else return a <=> b end end 0 end |