class Version
Definitions
def self.update_version(line)
If the line contains a version constant, update it using the provided block.
Implementation
def self.update_version(line)
if match = line.match(LINE_PATTERN)
parts = match[:parts].split(/\./).map(&:to_i)
suffix = match[:suffix]
version = self.new(parts, suffix)
yield version
line.sub!(match[:version], version.join)
end
end
def join
Join all parts together to form a version string.
Implementation
def join
if @suffix
return "#{@parts.join('.')}-#{@suffix}"
else
return @parts.join('.')
end
end
def to_s
The version string with a "v" prefix.
Implementation
def to_s
"v#{join}"
end