Method: Comet::Version.compare

Defined in:
lib/comet/version.rb

.compare(version_a, version_b) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/comet/version.rb', line 12

def self.compare(version_a, version_b)
  a_major, a_minor, a_patch = parse(version_a)
  b_major, b_minor, b_patch = parse(version_b)

  if a_major > b_major
    1
  elsif a_major < b_major
    -1
  else
    if a_minor > b_minor
      1
    elsif a_minor < b_minor
      -1
    else
      if a_patch > b_patch
        1
      elsif a_patch < b_patch
        -1
      else
        0
      end
    end
  end
end