class CookbookBumper::Version

Public Class Methods

new(ver_string) click to toggle source
# File lib/cookbook_bumper/version.rb, line 7
def initialize(ver_string)
  @ver_string = ver_string
  @major, @minor, @patch = parse(ver_string)
end

Public Instance Methods

==(other) click to toggle source
# File lib/cookbook_bumper/version.rb, line 18
def ==(other)
  parse(self) == parse(other)
end
bump() click to toggle source
# File lib/cookbook_bumper/version.rb, line 22
def bump
  @patch += 1
end
exact() click to toggle source
# File lib/cookbook_bumper/version.rb, line 30
def exact
  to_s.prepend('= ')
end
parse(ver_string) click to toggle source
# File lib/cookbook_bumper/version.rb, line 12
def parse(ver_string)
  ver_string.to_s.match(/(?<major>\d+)\.(?<minor>\d+)\.?(?<patch>\d*)/) do |v|
    [v[:major], v[:minor], v[:patch]].map(&:to_i)
  end
end
to_s() click to toggle source
# File lib/cookbook_bumper/version.rb, line 26
def to_s
  [@major, @minor, @patch].join('.')
end