Sha256: f54c7ff04e8a3ad846d272be99d371aaa034d4c8cbc35b058793cd73837d753b
Contents?: true
Size: 516 Bytes
Versions: 9
Compression:
Stored size: 516 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(version_a, version_b) return 0 if version_a == version_b splitted_a, splitted_b = version_a.split('.'), version_b.split('.') splitted_a.each_with_index do |a_node, idx| b_node = splitted_b[idx] break if a_node < b_node return 1 if a_node > b_node end return -1 end end
Version data entries
9 entries across 9 versions & 1 rubygems