Class: Bump::VersionNumber
- Inherits:
-
Object
- Object
- Bump::VersionNumber
- Defined in:
- lib/bump/domain/version_number.rb
Overview
The version number model
Instance Attribute Summary collapse
-
#preid ⇒ Object
writeonly
Sets the attribute preid.
Instance Method Summary collapse
-
#bump(level) ⇒ void
Bumps the version at the given level.
-
#initialize(major, minor, patch, preid = nil) ⇒ VersionNumber
constructor
A new instance of VersionNumber.
-
#to_s ⇒ String
Returns the string representation of the version.
Constructor Details
#initialize(major, minor, patch, preid = nil) ⇒ VersionNumber
Returns a new instance of VersionNumber.
10 11 12 13 14 15 |
# 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 |
Instance Attribute Details
#preid=(value) ⇒ Object (writeonly)
Sets the attribute preid
4 5 6 |
# File 'lib/bump/domain/version_number.rb', line 4 def preid=(value) @preid = value end |
Instance Method Details
#bump(level) ⇒ void
This method returns an undefined value.
Bumps the version at the given level
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 ⇒ String
Returns the string representation of the version
38 39 40 41 42 43 44 |
# 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 |