class Releasetool::Version

Attributes

ident[R]

Public Class Methods

new(ident) click to toggle source
# File lib/releasetool/version.rb, line 4
def initialize(ident)
  raise "Not a valid version identifier: #{ident.inspect}" unless ident.is_a?(String)
  @ident = ident
end
normalized(major, minor, patch) click to toggle source
# File lib/releasetool/version.rb, line 41
def self.normalized(major, minor, patch)
  new("v#{major}.#{minor}.#{patch}")
end

Public Instance Methods

==(other) click to toggle source
# File lib/releasetool/version.rb, line 37
def ==(other)
  other.is_a?(Releasetool::Version) && ident == other.ident
end
next_major() click to toggle source
# File lib/releasetool/version.rb, line 17
def next_major
  self.class.normalized(incremented(segments[0]), 0, 0)
end
next_minor() click to toggle source
# File lib/releasetool/version.rb, line 13
def next_minor
  self.class.normalized(segments[0], incremented(segments[1]), 0)
end
next_patch() click to toggle source
# File lib/releasetool/version.rb, line 9
def next_patch
  self.class.normalized(segments[0], segments[1], incremented(segments[2]))
end
to_s() click to toggle source
# File lib/releasetool/version.rb, line 21
def to_s
  if @ident[0] == "v"
    @ident
  else
    "v#{@ident}"
  end
end
to_s_without_v() click to toggle source
# File lib/releasetool/version.rb, line 29
def to_s_without_v
  if @ident[0] == "v"
    @ident[1..-1]
  else
    @ident
  end
end

Private Instance Methods

incremented(v) click to toggle source
# File lib/releasetool/version.rb, line 46
def incremented(v)
  raise "Can't work out next version from #{self}" unless v.to_i.to_s == v
  v.to_i + 1
end
segments() click to toggle source
# File lib/releasetool/version.rb, line 51
def segments
  @segments ||= to_s_without_v.split(".")
end