Class: Cassandra::Tuple
- Inherits:
-
Object
- Object
- Cassandra::Tuple
- Includes:
- Enumerable
- Defined in:
- lib/cassandra/tuple.rb
Instance Method Summary collapse
-
#[](i) ⇒ Object
Value of the tuple at position
i
. -
#[]=(i, value) ⇒ Object
Value of the tuple at position
i
. -
#each {|value| ... } ⇒ Object
Iterates over all values of the tuple.
- #eql?(other) ⇒ Boolean (also: #==)
-
#fetch(i) ⇒ Object
Value of the tuple at position
i
. -
#initialize(*values) ⇒ Tuple
constructor
Constructs a tuple with given values.
- #inspect ⇒ Object
-
#size ⇒ Integer
Returns tuple size.
-
#to_s ⇒ Object
String representation of the tuple.
Constructor Details
#initialize(*values) ⇒ Tuple
Constructs a tuple with given values
65 66 67 |
# File 'lib/cassandra/tuple.rb', line 65 def initialize(*values) @values = values end |
Instance Method Details
#[](i) ⇒ Object
Returns value of the tuple at position i
.
79 80 81 |
# File 'lib/cassandra/tuple.rb', line 79 def [](i) @values[Integer(i)] end |
#[]=(i, value) ⇒ Object
Returns value of the tuple at position i
.
98 99 100 101 102 |
# File 'lib/cassandra/tuple.rb', line 98 def []=(i, value) i = Integer(i) raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}" if i < 0 || i >= @values.size @values[i] = value end |
#each {|value| ... } ⇒ Object
Iterates over all values of the tuple
71 72 73 74 |
# File 'lib/cassandra/tuple.rb', line 71 def each(&block) @values.each(&block) self end |
#eql?(other) ⇒ Boolean Also known as: ==
119 120 121 |
# File 'lib/cassandra/tuple.rb', line 119 def eql?(other) other == @values end |
#fetch(i) ⇒ Object
Returns value of the tuple at position i
.
87 88 89 90 91 |
# File 'lib/cassandra/tuple.rb', line 87 def fetch(i) i = Integer(i) raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}" if i < 0 || i >= @values.size @values[i] end |
#inspect ⇒ Object
115 116 117 |
# File 'lib/cassandra/tuple.rb', line 115 def inspect "#<Cassandra::Tuple:0x#{self.object_id.to_s(16)} #{to_s}>" end |
#size ⇒ Integer
Returns tuple size
106 107 108 |
# File 'lib/cassandra/tuple.rb', line 106 def size @values.size end |
#to_s ⇒ Object
String representation of the tuple
111 112 113 |
# File 'lib/cassandra/tuple.rb', line 111 def to_s "(#{@values.map(&:to_s).join(', ')})" end |