class Version
Constants
- InvalidRequire
- InvalidVersion
- MSGS
- REQUIRE
- VERSION
Attributes
Public Class Methods
Source
# File lib/dpl/support/version.rb, line 17 def initialize(str) @nums = split(str) || raise(InvalidVersion, MSGS[:version] % str) end
Public Instance Methods
Source
# File lib/dpl/support/version.rb, line 41 def !=(other) trunc(other.size).to_a != other.to_a end
Source
# File lib/dpl/support/version.rb, line 45 def <=>(other) to_a <=> other.to_a end
Source
# File lib/dpl/support/version.rb, line 37 def ==(other) trunc(other.size).to_a == other.to_a end
Source
# File lib/dpl/support/version.rb, line 55 def bump ix = nums[1] ? -2 : -1 nums[ix] = nums[ix] + 1 nums[-1] = nums[-1] = 0 if nums[1] self end
Source
# File lib/dpl/support/version.rb, line 21 def satisfies?(str) send(*parse(str) || raise(InvalidRequire, MSGS[:require] % str)) end
Source
# File lib/dpl/support/version.rb, line 62 def trunc(size) @nums = nums[0..size - 1] self end
Private Instance Methods
Source
# File lib/dpl/support/version.rb, line 79 def parse(str) op, version = str =~ REQUIRE && [::Regexp.last_match(1), ::Regexp.last_match(2)] op = '==' if op == '=' [op, Version.new(version)] if op end
Source
# File lib/dpl/support/version.rb, line 75 def split(str) str =~ VERSION && [::Regexp.last_match(1), ::Regexp.last_match(2), ::Regexp.last_match(3)].compact.map(&:to_i) end