Class: Cassandra::Types::Set
- Inherits:
-
Cassandra::Type
- Object
- Cassandra::Type
- Cassandra::Types::Set
- 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 Set.
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#new(*value) ⇒ Set
Coerces the value to Set.
-
#to_s ⇒ String
"set<type>"
.
Instance Method Details
#assert(value, message = nil, &block) ⇒ void
This method returns an undefined value.
Asserts that a given value is an Set
817 818 819 820 821 822 823 |
# File 'lib/cassandra/types.rb', line 817 def assert(value, = nil, &block) Util.assert_instance_of(::Set, value, , &block) value.each do |v| Util.assert_type(@value_type, v, , &block) end nil end |
#eql?(other) ⇒ Boolean Also known as: ==
840 841 842 |
# File 'lib/cassandra/types.rb', line 840 def eql?(other) other.is_a?(Set) && @value_type == other.value_type end |
#hash ⇒ Object
831 832 833 834 835 836 837 838 |
# File 'lib/cassandra/types.rb', line 831 def hash @hash ||= begin h = 17 h = 31 * h + @kind.hash h = 31 * h + @value_type.hash h end end |
#new(*value) ⇒ Set
Coerces the value to Set
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
# File 'lib/cassandra/types.rb', line 788 def new(*value) value = value.first if value.one? case value when ::Array result = ::Set.new value.each do |v| Util.assert_type(@value_type, v) result << v end result when ::Set value.each do |v| Util.assert_type(@value_type, v) end value else Util.assert_type(@value_type, value) ::Set[value] end end |
#to_s ⇒ String
Returns "set<type>"
.
827 828 829 |
# File 'lib/cassandra/types.rb', line 827 def to_s "set<#{@value_type}>" end |