class GitBumper::BuildTag
This object represents a “build” tag. These tags are expected to have the format PREFIX.BUILD_NUMBER (e.g. v1, v2, a1, a2). It provides some methods to parse, increment and compare tags.
Constants
- REGEX
Attributes
build[RW]
prefix[R]
Public Class Methods
new(prefix, build)
click to toggle source
@param prefix [String] @param build [Fixnum]
# File lib/git_bumper/build_tag.rb, line 25 def initialize(prefix, build) @prefix = prefix @build = build end
parse(str)
click to toggle source
Parses a string into a BuildTag
object.
@param str [String] @return [BuildTag] or false if str has an invalid format
# File lib/git_bumper/build_tag.rb, line 12 def self.parse(str) matches = str.scan(REGEX).flatten return false if matches.empty? new(matches[0], matches[1].to_i) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/git_bumper/build_tag.rb, line 40 def <=>(other) build <=> other.build end
increment(*)
click to toggle source
Increments the build number.
# File lib/git_bumper/build_tag.rb, line 36 def increment(*) @build += 1 end
to_s()
click to toggle source
@return [String]
# File lib/git_bumper/build_tag.rb, line 31 def to_s "#{prefix}#{build}" end