Class: U3dCore::Version
- Inherits:
-
Object
- Object
- U3dCore::Version
- Includes:
- Comparable
- Defined in:
- lib/u3d_core/version.rb
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
- #<=>(other) ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
29 30 31 |
# File 'lib/u3d_core/version.rb', line 29 def initialize(version) @major, @minor, @patch = version.split('.').map(&:to_i) end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
27 28 29 |
# File 'lib/u3d_core/version.rb', line 27 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
27 28 29 |
# File 'lib/u3d_core/version.rb', line 27 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
27 28 29 |
# File 'lib/u3d_core/version.rb', line 27 def patch @patch end |
Instance Method Details
#<=>(other) ⇒ Object
41 42 43 44 45 |
# File 'lib/u3d_core/version.rb', line 41 def <=>(other) (major <=> other.major).nonzero? || (minor <=> other.minor).nonzero? || patch <=> other.patch end |
#to_a ⇒ Object
33 34 35 |
# File 'lib/u3d_core/version.rb', line 33 def to_a [major, minor, patch].compact end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/u3d_core/version.rb', line 37 def to_s to_a.join('.') end |