| … | |
… | |
| 23 | def <=>(other) |
23 | def <=>(other) |
| 24 | len = @version.length |
24 | len = @version.length |
| 25 | len = other.version.length unless other.version.length < @version.length |
25 | len = other.version.length unless other.version.length < @version.length |
| 26 | for ti in 0...len # => First of all, check the version |
26 | for ti in 0...len # => First of all, check the version |
| 27 | if @version[ti] == nil && other.version[ti] == nil |
27 | if @version[ti] == nil && other.version[ti] == nil |
| 28 | puts "break at #{ti}" |
|
|
| 29 | break |
28 | break |
| 30 | else |
29 | else |
| 31 | ov = other.version[ti].to_i |
30 | ov = other.version[ti].to_i |
| 32 | ov = 0 unless ov |
31 | ov = 0 unless ov |
| 33 | cv = @version[ti].to_i |
32 | cv = @version[ti].to_i |
| 34 | cv = 0 unless cv |
33 | cv = 0 unless cv |
| 35 | puts "not break at #{ti} [#{cv} #{ov}]" |
|
|
| 36 | if ov < cv |
34 | if ov < cv |
| 37 | # => if there's no indexed value on other (and we're not 0), |
35 | # => if there's no indexed value on other (and we're not 0), |
| 38 | # or it's lesser, return -1 (minor) |
36 | # or it's lesser, return -1 (minor) |
| 39 | return 1 |
37 | return 1 |
| 40 | elsif ( ov > cv ) # => if the other has a greater index return 1 (major) |
38 | elsif ( ov > cv ) # => if the other has a greater index return 1 (major) |