Class: SemverDialects::BaseVersion
- Inherits:
-
Object
- Object
- SemverDialects::BaseVersion
- Includes:
- Comparable
- Defined in:
- lib/semver_dialects/base_version.rb
Overview
rubocop:todo Style/Documentation
Direct Known Subclasses
Apk::Version, Maven::Version, Rpm::ReleaseTag, Rpm::Version, Semver2::PrereleaseTag, Semver2::Version
Instance Attribute Summary collapse
-
#addition ⇒ Object
readonly
Returns the value of attribute addition.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(tokens, addition: nil) ⇒ BaseVersion
constructor
A new instance of BaseVersion.
-
#is_zero? ⇒ Boolean
Returns true if the version tokens are equivalent to zero and the addition is also equivalent to zero.
- #to_s ⇒ Object
Constructor Details
#initialize(tokens, addition: nil) ⇒ BaseVersion
Returns a new instance of BaseVersion.
26 27 28 29 |
# File 'lib/semver_dialects/base_version.rb', line 26 def initialize(tokens, addition: nil) @tokens = tokens @addition = addition end |
Instance Attribute Details
#addition ⇒ Object (readonly)
Returns the value of attribute addition.
24 25 26 |
# File 'lib/semver_dialects/base_version.rb', line 24 def addition @addition end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
24 25 26 |
# File 'lib/semver_dialects/base_version.rb', line 24 def tokens @tokens end |
Instance Method Details
#<=>(other) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/semver_dialects/base_version.rb', line 37 def <=>(other) cmp = compare_tokens(tokens, other.tokens) return cmp unless cmp.zero? compare_additions(addition, other.addition) end |
#is_zero? ⇒ Boolean
Returns true if the version tokens are equivalent to zero and the addition is also equivalent to zero.
46 47 48 49 50 51 52 |
# File 'lib/semver_dialects/base_version.rb', line 46 def is_zero? # rubocop:todo Naming/PredicateName return false if compare_tokens(tokens, [0]) != 0 return true if addition.nil? addition.is_zero? end |
#to_s ⇒ Object
31 32 33 34 35 |
# File 'lib/semver_dialects/base_version.rb', line 31 def to_s main = tokens.join('.') main += "-#{addition}" if addition main end |