Class: U3d::UnityVersionComparator
- Inherits:
-
Object
- Object
- U3d::UnityVersionComparator
- Includes:
- Comparable
- Defined in:
- lib/u3d/unity_version_number.rb
Constant Summary collapse
- RELEASE_LETTER_STRENGTH =
{ a: 1, b: 2, f: 3, p: 4 }.freeze
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version) ⇒ UnityVersionComparator
constructor
A new instance of UnityVersionComparator.
- #inspect ⇒ Object
Constructor Details
#initialize(version) ⇒ UnityVersionComparator
Returns a new instance of UnityVersionComparator.
64 65 66 67 |
# File 'lib/u3d/unity_version_number.rb', line 64 def initialize(version) version = UnityVersionNumber.new(version.to_s) @version = version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
50 51 52 |
# File 'lib/u3d/unity_version_number.rb', line 50 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/u3d/unity_version_number.rb', line 52 def <=>(other) comp = @version.parts[0] <=> other.version.parts[0] return comp if comp.nonzero? comp = @version.parts[1] <=> other.version.parts[1] return comp if comp.nonzero? comp = @version.parts[2] <=> other.version.parts[2] return comp if comp.nonzero? comp = RELEASE_LETTER_STRENGTH[@version.parts[3].to_sym] <=> RELEASE_LETTER_STRENGTH[other.version.parts[3].to_sym] return comp if comp.nonzero? return @version.parts[4] <=> other.version.parts[4] end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/u3d/unity_version_number.rb', line 69 def inspect @version end |