Class: MacAdmin::Version
- Inherits:
-
Object
- Object
- MacAdmin::Version
- Defined in:
- lib/macadmin/version.rb
Overview
Version
-
Class for working with the version number
Constant Summary collapse
- FILE =
File.('version.yaml')
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#patch ⇒ Object
Returns the value of attribute patch.
Class Method Summary collapse
-
.init_with_string(version) ⇒ Object
Create from String - ie.
-
.load_yaml_file(file = FILE) ⇒ Object
Init from a YAML file.
Instance Method Summary collapse
-
#bump_major ⇒ Object
Increment the major version number.
-
#bump_minor ⇒ Object
Increment the minor version number.
-
#bump_patch ⇒ Object
Increment the patch version number.
-
#save(file = FILE) ⇒ Object
Serialize the object to YAML file.
-
#to_s ⇒ Object
Returns a version String.
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
11 12 13 |
# File 'lib/macadmin/version.rb', line 11 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
11 12 13 |
# File 'lib/macadmin/version.rb', line 11 def minor @minor end |
#patch ⇒ Object
Returns the value of attribute patch.
11 12 13 |
# File 'lib/macadmin/version.rb', line 11 def patch @patch end |
Class Method Details
.init_with_string(version) ⇒ Object
Create from String
-
ie. “0.0.1”
15 16 17 |
# File 'lib/macadmin/version.rb', line 15 def self.init_with_string(version) @major, @minor, @patch = version.split(".").each(&:to_i) end |
.load_yaml_file(file = FILE) ⇒ Object
Init from a YAML file
20 21 22 |
# File 'lib/macadmin/version.rb', line 20 def self.load_yaml_file(file = FILE) YAML.load_file FILE end |
Instance Method Details
#bump_major ⇒ Object
Increment the major version number
30 31 32 |
# File 'lib/macadmin/version.rb', line 30 def bump_major @major += 1 end |
#bump_minor ⇒ Object
Increment the minor version number
35 36 37 |
# File 'lib/macadmin/version.rb', line 35 def bump_minor @minor += 1 end |
#bump_patch ⇒ Object
Increment the patch version number
40 41 42 |
# File 'lib/macadmin/version.rb', line 40 def bump_patch @patch += 1 end |
#save(file = FILE) ⇒ Object
Serialize the object to YAML file
45 46 47 |
# File 'lib/macadmin/version.rb', line 45 def save(file = FILE) File.open(file, 'w') { |f| f.write self.to_yaml } end |
#to_s ⇒ Object
Returns a version String
25 26 27 |
# File 'lib/macadmin/version.rb', line 25 def to_s "#{@major}.#{@minor}.#{@patch}" end |