Class: Ore::Versions::Version
- Inherits:
-
Gem::Version
- Object
- Gem::Version
- Ore::Versions::Version
- Defined in:
- lib/ore/versions/version.rb
Overview
Represents a standard three-number version.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
The build string.
-
#major ⇒ Object
readonly
Major version number.
-
#minor ⇒ Object
readonly
Minor version number.
-
#patch ⇒ Object
readonly
Patch version number.
Class Method Summary collapse
-
.parse(string) ⇒ Version
Parses a version string.
Instance Method Summary collapse
-
#initialize(major, minor, patch, build = nil) ⇒ Version
constructor
Creates a new version.
Constructor Details
#initialize(major, minor, patch, build = nil) ⇒ Version
Creates a new version.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ore/versions/version.rb', line 41 def initialize(major,minor,patch,build=nil) @major = (major || 0) @minor = (minor || 0) @patch = (patch || 0) @build = build numbers = [@major,@minor,@patch] numbers << @build if @build super(numbers.join('.')) end |
Instance Attribute Details
#build ⇒ Object (readonly)
The build string
24 25 26 |
# File 'lib/ore/versions/version.rb', line 24 def build @build end |
#major ⇒ Object (readonly)
Major version number
15 16 17 |
# File 'lib/ore/versions/version.rb', line 15 def major @major end |
#minor ⇒ Object (readonly)
Minor version number
18 19 20 |
# File 'lib/ore/versions/version.rb', line 18 def minor @minor end |
#patch ⇒ Object (readonly)
Patch version number
21 22 23 |
# File 'lib/ore/versions/version.rb', line 21 def patch @patch end |
Class Method Details
.parse(string) ⇒ Version
Parses a version string.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ore/versions/version.rb', line 62 def self.parse(string) major, minor, patch, build = string.split('.',4) return self.new( (major || 0).to_i, (minor || 0).to_i, (patch || 0).to_i, build ) end |