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

Version Path
ajaxlibs-0.1.12 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.11 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.10 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.9 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.8 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.7 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.6 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.4 lib/ajaxlibs/versions_tools.rb
ajaxlibs-0.1.3 lib/ajaxlibs/versions_tools.rb