Class: TeradataCli::FieldType

Inherits:
Object
  • Object
show all
Defined in:
lib/teradata-cli/connection.rb

Overview

Unsupported Types: BLOB 400 BLOB_DEFERRED 404 BLOB_LOCATOR 408 CLOB 416 CLOB_DEFERRED 420 CLOB_LOCATOR 424 GRAPHIC_NN 468 GRAPHIC_N 469 LONG_VARBYTE_NN 696 LONG_VARBYTE_N 697 LONG_VARCHAR_NN 456 LONG_VARCHAR_N 457 LONG_VARGRAPHIC_NN 472 LONG_VARGRAPHIC_N 473 VARGRAPHIC_NN 464 VARGRAPHIC_N 465

Constant Summary collapse

@@types =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name, type_code, len, name, format, title, extractor) ⇒ FieldType

Returns a new instance of FieldType.



851
852
853
854
855
856
857
858
859
# File 'lib/teradata-cli/connection.rb', line 851

def initialize(type_name, type_code, len, name, format, title, extractor)
  @type_name = type_name
  @type_code = type_code
  @length = len
  @name = name
  @format = format
  @title = title
  @extractor = extractor
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



864
865
866
# File 'lib/teradata-cli/connection.rb', line 864

def format
  @format
end

#nameObject (readonly)

Returns the value of attribute name.



863
864
865
# File 'lib/teradata-cli/connection.rb', line 863

def name
  @name
end

#titleObject (readonly)

Returns the value of attribute title.



865
866
867
# File 'lib/teradata-cli/connection.rb', line 865

def title
  @title
end

#type_codeObject (readonly)

Returns the value of attribute type_code.



862
863
864
# File 'lib/teradata-cli/connection.rb', line 862

def type_code
  @type_code
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



861
862
863
# File 'lib/teradata-cli/connection.rb', line 861

def type_name
  @type_name
end

Class Method Details

.code_namesObject



847
848
849
# File 'lib/teradata-cli/connection.rb', line 847

def FieldType.code_names
  @@types.values.map {|name, c| name }
end

.codesObject



843
844
845
# File 'lib/teradata-cli/connection.rb', line 843

def FieldType.codes
  @@types.keys
end

.create(code, len, name, format, title, extractor) ⇒ Object



837
838
839
840
841
# File 'lib/teradata-cli/connection.rb', line 837

def FieldType.create(code, len, name, format, title, extractor)
  type_name, type_class = @@types[code]
  raise MetaDataFormatError, "unknown type code: #{code}" unless name
  type_class.new(type_name, code, len, name, format, title, extractor)
end

Instance Method Details

#inspectObject



871
872
873
# File 'lib/teradata-cli/connection.rb', line 871

def inspect
  "\#<FieldType #{@name} (#{@type_name}:#{@type_code})>"
end

#to_sObject



867
868
869
# File 'lib/teradata-cli/connection.rb', line 867

def to_s
  "(#{@name} #{@type_name}:#{@type_code})"
end

#unmarshal(f) ⇒ Object

default implementation: only read as string.



876
877
878
# File 'lib/teradata-cli/connection.rb', line 876

def unmarshal(f)
  f.read(@length).rstrip
end