Class: Bumper::Version
- Inherits:
-
Object
- Object
- Bumper::Version
- Defined in:
- lib/bumper/version.rb
Instance Method Summary collapse
- #bump(part) ⇒ Object
-
#initialize(v) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
- #write(f) ⇒ Object
Constructor Details
#initialize(v) ⇒ Version
Returns a new instance of Version.
14 15 16 17 18 19 20 21 22 |
# File 'lib/bumper/version.rb', line 14 def initialize(v) @v = {} if v =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ @v[:major] = $1.to_i @v[:minor] = $2.to_i @v[:revision] = $3.to_i @v[:build] = $4 end end |
Instance Method Details
#bump(part) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bumper/version.rb', line 24 def bump(part) version = @v[part] = @v[part].succ return version if part == :build @v[:build] = '0' if @v[:build] return version if part == :revision @v[:revision] = 0 return version if part == :minor @v[:minor] = 0 version end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/bumper/version.rb', line 37 def to_s [major, minor, revision, build].compact.join('.') end |
#write(f) ⇒ Object
41 42 43 |
# File 'lib/bumper/version.rb', line 41 def write(f) File.open(f,'w'){ |h| h.write(self.to_s) } end |