Sha256: 8f7841f701c75c882272bc395b2b1d3a6b005e3907fd233b0cf7b8123657feea

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 Bytes

Contents

module Cassandra
  # Abstract base class for comparable numeric column name types
  class CustomComparable
    class TypeError < ::TypeError #:nodoc:
    end
  
    def <=>(other)
      self.to_i <=> other.to_i
    end
    
    def hash
      @bytes.hash
    end
    
    def eql?(other)
      other.is_a?(Comparable) and @bytes == other.to_s
    end    
    
    def ==(other)
      other.respond_to?(:to_i) && self.to_i == other.to_i
    end
    
    def to_s
      @bytes
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sessionm-cassandra_object-4.0.32 lib/cassandra_object/custom_comparable.rb
sessionm-cassandra_object-4.0.31 lib/cassandra_object/custom_comparable.rb
sessionm-cassandra_object-4.0.30 lib/cassandra_object/custom_comparable.rb