class Cassandra::Tuple
Public Class Methods
new(*values)
click to toggle source
Constructs a tuple with given values
# File lib/cassandra/tuple.rb 65 def initialize(*values) 66 @values = values 67 end
Public Instance Methods
[](i)
click to toggle source
@param i [Integer] numeric index of the value inside the tuple, must
be `0 < i < tuple.size`
@return [Object] value of the tuple at position `i`
# File lib/cassandra/tuple.rb 79 def [](i) 80 @values[Integer(i)] 81 end
[]=(i, value)
click to toggle source
@param i [Integer] numeric index of the value inside the tuple, must
be `0 < i < tuple.size`
@param value [Object] a value to assign at position `i` @raise [IndexError] when index is outside of tuple bounds @return [Object] value of the tuple at position `i`
# File lib/cassandra/tuple.rb 98 def []=(i, value) 99 i = Integer(i) 100 raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}" if i < 0 || i >= @values.size 101 @values[i] = value 102 end
each(&block)
click to toggle source
Iterates over all values of the tuple @yieldparam value [Object] current value
# File lib/cassandra/tuple.rb 71 def each(&block) 72 @values.each(&block) 73 self 74 end
eql?(other)
click to toggle source
@private
# File lib/cassandra/tuple.rb 121 def eql?(other) 122 other == @values 123 end
Also aliased as: ==
fetch(i)
click to toggle source
@param i [Integer] numeric index of the value inside the tuple, must
be `0 < i < tuple.size`
@raise [IndexError] when index is outside of tuple bounds @return [Object] value of the tuple at position `i`
# File lib/cassandra/tuple.rb 87 def fetch(i) 88 i = Integer(i) 89 raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}" if i < 0 || i >= @values.size 90 @values[i] 91 end
hash()
click to toggle source
@private
# File lib/cassandra/tuple.rb 127 def hash 128 @values.inject(17) {|h, v| 31 * h + v.hash} 129 end
inspect()
click to toggle source
@private
# File lib/cassandra/tuple.rb 116 def inspect 117 "#<Cassandra::Tuple:0x#{object_id.to_s(16)} []=#{@values.inspect}>" 118 end
size()
click to toggle source
Returns tuple size @return [Integer] tuple size
# File lib/cassandra/tuple.rb 106 def size 107 @values.size 108 end
to_s()
click to toggle source
String representation of the tuple
# File lib/cassandra/tuple.rb 111 def to_s 112 "(#{@values.map(&:to_s).join(', ')})" 113 end