Method: Luffa::Version.compare
- Defined in:
- lib/luffa/version.rb
.compare(a, b) ⇒ Integer
Compare version ‘a` to version `b`.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/luffa/version.rb', line 137 def self.compare(a, b) if a.major != b.major return a.major > b.major ? 1 : -1 end if a.minor != b.minor return a.minor.to_i > b.minor.to_i ? 1 : -1 end if a.patch != b.patch return a.patch.to_i > b.patch.to_i ? 1 : -1 end return -1 if a.pre and (not a.pre_version) and b.pre_version return 1 if a.pre_version and b.pre and (not b.pre_version) return -1 if a.pre and (not b.pre) return 1 if (not a.pre) and b.pre return -1 if a.pre_version and (not b.pre_version) return 1 if (not a.pre_version) and b.pre_version if a.pre_version != b.pre_version return a.pre_version.to_i > b.pre_version.to_i ? 1 : -1 end 0 end |