Class: Mmi::Semver
- Inherits:
-
Object
- Object
- Mmi::Semver
- Defined in:
- lib/mmi/semver.rb
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
Instance Method Summary collapse
-
#initialize(major, minor, patch) ⇒ Semver
constructor
A new instance of Semver.
Constructor Details
#initialize(major, minor, patch) ⇒ Semver
Returns a new instance of Semver.
7 8 9 10 11 |
# File 'lib/mmi/semver.rb', line 7 def initialize(major, minor, patch) self.major = major self.minor = minor self.patch = patch end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
3 4 5 |
# File 'lib/mmi/semver.rb', line 3 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
4 5 6 |
# File 'lib/mmi/semver.rb', line 4 def minor @minor end |
#patch ⇒ Object
Returns the value of attribute patch.
5 6 7 |
# File 'lib/mmi/semver.rb', line 5 def patch @patch end |
Class Method Details
.parse(version) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/mmi/semver.rb', line 13 def self.parse(version) if (m = /\A(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)\z/.match(version.strip)) new(m[:major].to_i, m[:minor].to_i, m[:patch].to_i) else raise "Version string not in valid format: #{version.inspect}" end end |