class UserAgent::Version
def <=>(other)
def <=>(other) case other when Version if @comparable to_a.zip(other.to_a).each do |a, b| if b.nil? return -1 elsif a.nil? return 1 elsif a.is_a?(String) && b.is_a?(Integer) return -1 elsif a.is_a?(Integer) && b.is_a?(String) return 1 elsif a == b next else return a <=> b end end 0 else to_s == other.to_s ? 0 : nil end when String self <=> self.class.new(other) else raise ArgumentError, "comparison of Version with #{other.inspect} failed" end end