class Bump::VersionNumber

The version number model

Attributes

preid[W]

Public Class Methods

new(major, minor, patch, preid = nil) click to toggle source

@param [Integer] major @param [Integer] minor @param [Integer] patch @param [String, nil] preid

# File lib/bump/domain/version_number.rb, line 10
def initialize(major, minor, patch, preid = nil)
  @major = major
  @minor = minor
  @patch = patch
  @preid = preid
end

Public Instance Methods

bump(level) click to toggle source

Bumps the version at the given level

@param [Symbol] level @return [void]

# File lib/bump/domain/version_number.rb, line 21
def bump(level)
  case level
  when :major
    @major += 1
    @minor = 0
    @patch = 0
  when :minor
    @minor += 1
    @patch = 0
  when :patch
    @patch += 1
  end
  @preid = nil
end
to_s() click to toggle source

Returns the string representation of the version @return [String]

# File lib/bump/domain/version_number.rb, line 38
def to_s
  label = @major.to_s + '.' + @minor.to_s + '.' + @patch.to_s

  label = label + '-' + @preid if @preid

  label
end