Class: SemverDialects::Semver2::Version

Inherits:
BaseVersion show all
Defined in:
lib/semver_dialects/semver2.rb

Overview

rubocop:todo Style/Documentation

Instance Attribute Summary

Attributes inherited from BaseVersion

#addition, #tokens

Instance Method Summary collapse

Methods inherited from BaseVersion

#is_zero?, #to_s

Constructor Details

#initialize(tokens, prerelease_tag: nil) ⇒ Version

rubocop:todo Lint/MissingSuper



11
12
13
14
# File 'lib/semver_dialects/semver2.rb', line 11

def initialize(tokens, prerelease_tag: nil) # rubocop:todo Lint/MissingSuper
  @tokens = tokens
  @addition = prerelease_tag
end

Instance Method Details

#<=>(other) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/semver_dialects/semver2.rb', line 16

def <=>(other)
  if (idx = tokens.index(ANY_NUMBER))
    a = tokens[0..(idx - 1)]
    b = other.tokens[0..(idx - 1)]
    return compare_tokens(a, b)
  end

  if (idx = other.tokens.index(ANY_NUMBER))
    a = tokens[0..(idx - 1)]
    b = other.tokens[0..(idx - 1)]
    return compare_tokens(a, b)
  end

  super
end