Class: Vertica::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/vertica/column.rb

Overview

Class representing a column in a result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, data_type: nil, table_oid: nil, attribute_number: nil) ⇒ Column

Initializes a new Vertica::Column.

See Also:



34
35
36
37
38
39
# File 'lib/vertica/column.rb', line 34

def initialize(name: nil, data_type: nil, table_oid: nil, attribute_number: nil)
  @name             = name
  @table_oid        = table_oid
  @attribute_number = attribute_number
  @data_type        = data_type
end

Instance Attribute Details

#attribute_numberInteger? (readonly)

The attribute index in the table this column originates from. This can be nil if the volumn was computed, and was not soruced from a table

Returns:

  • (Integer, nil)

    the current value of attribute_number



12
13
14
# File 'lib/vertica/column.rb', line 12

def attribute_number
  @attribute_number
end

#data_typeVertica::DataType (readonly)

The type of the values in this column.

Returns:



12
13
14
# File 'lib/vertica/column.rb', line 12

def data_type
  @data_type
end

#nameString (readonly)

The name of the column

Returns:

  • (String)

    the current value of name



12
13
14
# File 'lib/vertica/column.rb', line 12

def name
  @name
end

#table_oidInteger? (readonly)

The OID of the table this column originates from. This can be nil if the volumn was computed, and was not soruced from a table

Returns:

  • (Integer, nil)

    the current value of table_oid



12
13
14
# File 'lib/vertica/column.rb', line 12

def table_oid
  @table_oid
end

Class Method Details

.build(name: nil, table_oid: nil, attribute_number: nil, data_format: 0, data_type_oid: nil, data_type_size: nil, data_type_modifier: nil) ⇒ Vertica::Column

Builds a new column instance based on the values provided by a Protocol::RowDescription message.

Parameters:

  • name (String) (defaults to: nil)

    The name of the column

  • table_oid (Integer, nil) (defaults to: nil)

    The OID of the table this column originates from. This can be nil if the volumn was computed, and was not soruced from a table

  • attribute_number (Integer, nil) (defaults to: nil)

    The attribute index in the table this column originates from. This can be nil if the volumn was computed, and was not soruced from a table

  • data_type_oid (Integer) (defaults to: nil)

    The object ID of the type.

  • data_type_size (Integer) (defaults to: nil)

    The size of the type.

  • data_type_modifier (Integer) (defaults to: nil)

    A modifier of the type.

  • data_format (Integer) (defaults to: 0)

    The serialization format of this type.

Returns:



25
26
27
28
# File 'lib/vertica/column.rb', line 25

def self.build(name: nil, table_oid: nil, attribute_number: nil, data_format: 0, data_type_oid: nil, data_type_size: nil, data_type_modifier: nil)
  data_type = Vertica::DataType.build(oid: data_type_oid, size: data_type_size, modifier: data_type_modifier, format: data_format)
  new(name: name, data_type: data_type, table_oid: table_oid, attribute_number: attribute_number)
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns true iff this record is equal to the other provided object

Returns:

  • (Boolean)

    Returns true iff this record is equal to the other provided object



42
43
44
45
# File 'lib/vertica/column.rb', line 42

def eql?(other)
  self.class === other && other.name == name && other.data_type == data_type &&
    other.table_oid == table_oid && other.attribute_number == attribute_number
end

#hashInteger

Returns a hash digtest of this object.

Returns:

  • (Integer)

    Returns a hash digtest of this object.



50
51
52
# File 'lib/vertica/column.rb', line 50

def hash
  [name, data_type, table_oid, attribute_number].hash
end

#inspectString

Returns a user-consumable string representation of this column.

Returns:

  • (String)

    Returns a user-consumable string representation of this column.



55
56
57
# File 'lib/vertica/column.rb', line 55

def inspect
  "#<#{self.class.name} name=#{name.inspect} data_type=#{data_type.inspect}>"
end