class Chewy::Runtime::Version

Attributes

major[R]
minor[R]
patch[R]

Public Class Methods

new(version) click to toggle source
# File lib/chewy/runtime/version.rb, line 7
def initialize(version)
  @major, @minor, @patch = *(version.to_s.split('.', 3) + ([0] * 3)).first(3).map(&:to_i)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/chewy/runtime/version.rb, line 15
def <=>(other)
  other = self.class.new(other) unless other.is_a?(self.class)
  [
    major <=> other.major,
    minor <=> other.minor,
    patch <=> other.patch
  ].detect(&:nonzero?) || 0
end
to_s() click to toggle source
# File lib/chewy/runtime/version.rb, line 11
def to_s
  [major, minor, patch].join('.')
end