Class: Cassandra::Types::List
- Inherits:
-
Cassandra::Type
- Object
- Cassandra::Type
- Cassandra::Types::List
- Defined in:
- lib/cassandra/types.rb
Instance Attribute Summary
Attributes inherited from Cassandra::Type
Instance Method Summary collapse
-
#assert(value, message = nil, &block) ⇒ void
Asserts that a given value is an Array.
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#new(*value) ⇒ Array
Coerces the value to Array.
-
#to_s ⇒ String
"list<type>"
.
Instance Method Details
#assert(value, message = nil, &block) ⇒ void
This method returns an undefined value.
Asserts that a given value is an Array
651 652 653 654 655 656 657 |
# File 'lib/cassandra/types.rb', line 651 def assert(value, = nil, &block) Util.assert_instance_of(::Array, value, , &block) value.each do |v| Util.assert_type(@value_type, v, , &block) end nil end |
#eql?(other) ⇒ Boolean Also known as: ==
674 675 676 |
# File 'lib/cassandra/types.rb', line 674 def eql?(other) other.is_a?(List) && @value_type == other.value_type end |
#hash ⇒ Object
665 666 667 668 669 670 671 672 |
# File 'lib/cassandra/types.rb', line 665 def hash @hash ||= begin h = 17 h = 31 * h + @kind.hash h = 31 * h + @value_type.hash h end end |
#new(*value) ⇒ Array
Coerces the value to Array
635 636 637 638 639 640 641 642 |
# File 'lib/cassandra/types.rb', line 635 def new(*value) value = Array(value.first) if value.one? value.each do |v| Util.assert_type(@value_type, v) end value end |
#to_s ⇒ String
Returns "list<type>"
.
661 662 663 |
# File 'lib/cassandra/types.rb', line 661 def to_s "list<#{@value_type}>" end |