Sha256: f4ba25d47bfe9af900f903fc6aeb03b1625017fceb640e2ee9200f85ff40982d
Contents?: true
Size: 443 Bytes
Versions: 3
Compression:
Stored size: 443 Bytes
Contents
# Tools to manipulate versions strings (for example 1.2.3) module Ajaxlibs::VersionsTools # Compare two versions and returns either : # * 1 if a > b # * 0 if a == b # * -1 if a < b def self.compare(a, b) return 0 if a == b splitted_a, splitted_b = a.split('.'), b.split('.') splitted_a.each_with_index do |node, i| break if node < splitted_b[i] return 1 if node > splitted_b[i] end return -1 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ajaxlibs-0.1.2 | lib/ajaxlibs/versions_tools.rb |
ajaxlibs-0.1.1 | lib/ajaxlibs/versions_tools.rb |
ajaxlibs-0.1.0 | lib/ajaxlibs/versions_tools.rb |