Class: Cassandra::Types::Tuple
- Inherits:
-
Cassandra::Type
- Object
- Cassandra::Type
- Cassandra::Types::Tuple
- Defined in:
- lib/cassandra/types.rb
Instance Method Summary collapse
-
#assert(value, message = nil, &block) ⇒ void
Asserts that a given value is an Cassandra::Tuple.
- #eql?(other) ⇒ Boolean (also: #==)
-
#kind ⇒ Symbol
:tuple
. -
#new(*values) ⇒ Cassandra::Tuple
Coerces the value to Cassandra::Tuple.
-
#to_s ⇒ String
"tuple<type, type, type...>"
.
Instance Method Details
#assert(value, message = nil, &block) ⇒ void
This method returns an undefined value.
Asserts that a given value is an Cassandra::Tuple
972 973 974 975 976 977 978 979 |
# File 'lib/cassandra/types.rb', line 972 def assert(value, = nil, &block) Util.assert_instance_of(Cassandra::Tuple, value, , &block) Util.assert(value.size <= @members.size, , &block) @members.each_with_index do |type, i| Util.assert_type(type, value[i], , &block) end nil end |
#eql?(other) ⇒ Boolean Also known as: ==
987 988 989 |
# File 'lib/cassandra/types.rb', line 987 def eql?(other) other.is_a?(Tuple) && @members == other.members end |
#kind ⇒ Symbol
Returns :tuple
.
945 946 947 |
# File 'lib/cassandra/types.rb', line 945 def kind :tuple end |
#new(*values) ⇒ Cassandra::Tuple
Coerces the value to Cassandra::Tuple
957 958 959 960 961 962 963 |
# File 'lib/cassandra/types.rb', line 957 def new(*values) Util.assert(values.size <= @members.size) { "too many values: #{values.size} out of max #{@members.size}" } values.each_with_index do |v, i| Util.assert_type(@members[i], v) end Cassandra::Tuple::Strict.new(@members, values) end |
#to_s ⇒ String
Returns "tuple<type, type, type...>"
.
983 984 985 |
# File 'lib/cassandra/types.rb', line 983 def to_s "tuple<#{@members.map(&:to_s).join(', ')}>" end |