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.
70 71 72 73 |
# File 'lib/u3d/unity_version_number.rb', line 70 def initialize(version) version = UnityVersionNumber.new(version.to_s) @version = version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
52 53 54 |
# File 'lib/u3d/unity_version_number.rb', line 52 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/u3d/unity_version_number.rb', line 54 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
75 76 77 |
# File 'lib/u3d/unity_version_number.rb', line 75 def inspect @version end |