Class: Cassandra::CustomComparable

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra_object/custom_comparable.rb

Overview

Abstract base class for comparable numeric column name types

Direct Known Subclasses

Long

Defined Under Namespace

Classes: TypeError

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



7
8
9
# File 'lib/cassandra_object/custom_comparable.rb', line 7

def <=>(other)
  self.to_i <=> other.to_i
end

#==(other) ⇒ Object



19
20
21
# File 'lib/cassandra_object/custom_comparable.rb', line 19

def ==(other)
  other.respond_to?(:to_i) && self.to_i == other.to_i
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/cassandra_object/custom_comparable.rb', line 15

def eql?(other)
  other.is_a?(Comparable) and @bytes == other.to_s
end

#hashObject



11
12
13
# File 'lib/cassandra_object/custom_comparable.rb', line 11

def hash
  @bytes.hash
end

#to_sObject



23
24
25
# File 'lib/cassandra_object/custom_comparable.rb', line 23

def to_s
  @bytes
end