A user-defined type value representation

Inherits

Object

Includes

  • Enumerable

Methods

self.

new

(*values)

Creates a UDT instance

Examples:
Various ways of creating the same UDT instance
Cassandra::UDT.new({'street' => '123 Main St.',
                    'city' => 'Whatever',
                    'state' => 'XZ',
                    'zip' => '10020'})

Cassandra::UDT.new(street: '123 Main St.',
                   city: 'Whatever',
                   state: 'XZ',
                   zip: '10020')

Cassandra::UDT.new('street', '123 Main St.',
                   'city', 'Whatever',
                   'state', 'XZ',
                   'zip', '10020')

Cassandra::UDT.new(:street, '123 Main St.',
                   :city, 'Whatever',
                   :state, 'XZ',
                   :zip, '10020')

Cassandra::UDT.new(['street', '123 Main St.'],
                   ['city', 'Whatever'],
                   ['state', 'XZ'],
                   ['zip', '10020'])

Cassandra::UDT.new([:street, '123 Main St.'],
                   [:city, 'Whatever'],
                   [:state, 'XZ'],
                   [:zip, '10020'])

Cassandra::UDT.new([['street', '123 Main St.'],
                    ['city', 'Whatever'],
                    ['state', 'XZ'],
                    ['zip', '10020']])

Cassandra::UDT.new([[:street, '123 Main St.'],
                    [:city, 'Whatever'],
                    [:state, 'XZ'],
                    [:zip, '10020']])
Parameters:
Name Type Details
values (Hash<String, Object>, Array<Array<String, Object>>, *Object or *Array<String, Object>)
  • UDT field values

respond_to?

(field)

Returns true if a field with a given name is present

Parameters:
Name Type Details
field Symbol method or name of the field
Returns:
Type Details
Boolean whether a field is present

[]

(field)

Returns value of the field.

Parameters:
Name Type Details
field (String or Integer) name or numeric index of the field to lookup
Returns:
Type Details
Object value of the field, or nil if the field is not present
Raises:
Type Details
ArgumentError when neither a numeric index nor a field name given

fetch

(field)

Returns value of the field.

Parameters:
Name Type Details
field (String or Integer) name or numeric index of the field to lookup
Returns:
Type Details
Object value of the field
Raises:
Type Details
IndexError when numeric index given is out of bounds
KeyError when field with a given name is not present
ArgumentError when neither a numeric index nor a field name given

has_field?

(field) aliased as: include?

Returns whether the field is present in this UDT

Parameters:
Name Type Details
field (String or Integer) name or numeric index of the field to lookup
Returns:
Type Details
Boolean whether the field is present in this UDT

[]=

(field, value)

Sets value of the field.

Parameters:
Name Type Details
field String name of the field to set
value Object new value for the field
Returns:
Type Details
Object value.
Raises:
Type Details
IndexError when numeric index given is out of bounds
KeyError when field with a given name is not present
ArgumentError when neither a numeric index nor a field name given

each

{|name, value| … }

Iterates over all fields of the UDT

Yield Parameters:
Name Type Details
name String field name
value Object field value
Returns:
Type Details
UDT self

size

Returns UDT size

Returns:
Type Details
Integer UDT size

to_h

Hash representation of the UDT

to_s

String representation of the UDT