Class: VersionManager
- Inherits:
-
Object
- Object
- VersionManager
- Defined in:
- lib/utils/version_manager.rb
Overview
Manages software versions with Major, Minor, and Patch components.
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Instance Method Summary collapse
-
#increment_major ⇒ Object
Increments the major version and resets minor and patch to 0.
-
#increment_minor ⇒ Object
Increments the minor version and resets patch to 0.
-
#increment_patch ⇒ Object
Increments the patch version.
-
#initialize(major = 0, minor = 0, patch = 0) ⇒ VersionManager
constructor
Initializes a new instance of VersionManager.
-
#to_s ⇒ String
Returns the version as a string in the format "major.minor.patch".
Constructor Details
#initialize(major = 0, minor = 0, patch = 0) ⇒ VersionManager
Initializes a new instance of VersionManager.
12 13 14 15 16 17 18 19 20 |
# File 'lib/utils/version_manager.rb', line 12 def initialize(major = 0, minor = 0, patch = 0) if major.is_a?(String) parse_version_string(major) else @major = major @minor = minor @patch = patch end end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
5 6 7 |
# File 'lib/utils/version_manager.rb', line 5 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
5 6 7 |
# File 'lib/utils/version_manager.rb', line 5 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
5 6 7 |
# File 'lib/utils/version_manager.rb', line 5 def patch @patch end |
Instance Method Details
#increment_major ⇒ Object
Increments the major version and resets minor and patch to 0.
23 24 25 26 27 |
# File 'lib/utils/version_manager.rb', line 23 def increment_major @major += 1 @minor = 0 @patch = 0 end |
#increment_minor ⇒ Object
Increments the minor version and resets patch to 0.
30 31 32 33 |
# File 'lib/utils/version_manager.rb', line 30 def increment_minor @minor += 1 @patch = 0 end |
#increment_patch ⇒ Object
Increments the patch version.
36 37 38 |
# File 'lib/utils/version_manager.rb', line 36 def increment_patch @patch += 1 end |
#to_s ⇒ String
Returns the version as a string in the format "major.minor.patch".
43 44 45 |
# File 'lib/utils/version_manager.rb', line 43 def to_s "#{@major}.#{@minor}.#{@patch}" end |