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.



848
849
850
851
852
853
854
855
856
# File 'lib/teradata-cli/connection.rb', line 848

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.



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

def format
  @format
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#type_codeObject (readonly)

Returns the value of attribute type_code.



859
860
861
# File 'lib/teradata-cli/connection.rb', line 859

def type_code
  @type_code
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



858
859
860
# File 'lib/teradata-cli/connection.rb', line 858

def type_name
  @type_name
end

Class Method Details

.code_namesObject



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

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

.codesObject



840
841
842
# File 'lib/teradata-cli/connection.rb', line 840

def FieldType.codes
  @@types.keys
end

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



834
835
836
837
838
# File 'lib/teradata-cli/connection.rb', line 834

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



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

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

#to_sObject



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

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

#unmarshal(f) ⇒ Object

default implementation: only read as string.



873
874
875
# File 'lib/teradata-cli/connection.rb', line 873

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