Sha256: 13ce16e9cea0beda774c6395c7602e13cf8d27b01a3f701c019c0e1500230c6d
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module Invoker class Version include Comparable attr_reader :major, :minor, :patch def initialize(number) t_major, t_minor, t_patch = number.split('.') @major = t_major.to_i @minor = t_minor.to_i @patch = t_patch.to_i end def to_a [major, minor, patch].compact end def <=>(version) (major.to_i <=> version.major.to_i).nonzero? || (minor.to_i <=> version.minor.to_i).nonzero? || patch.to_i <=> version.patch.to_i end def matches?(operator, number) version = Version.new(number) self == version return self == version if operator == '=' return self > version if operator == '>' return self < version if operator == '<' return version <= self && version.next > self if operator == '~>' end def next next_splits = to_a if next_splits.length == 1 next_splits[0] += 1 else next_splits[-2] += 1 next_splits[-1] = 0 end Version.new(next_splits.join('.')) end end VERSION = "1.5.8" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
invoker-1.5.8 | lib/invoker/version.rb |