Class: TeradataCli::SessionCharset

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ SessionCharset

Returns a new instance of SessionCharset.



58
59
60
# File 'lib/teradata-cli/utils.rb', line 58

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



62
63
64
# File 'lib/teradata-cli/utils.rb', line 62

def name
  @name
end

Class Method Details

.intern(arg) ⇒ Object



54
55
56
# File 'lib/teradata-cli/utils.rb', line 54

def SessionCharset.intern(arg)
  arg.kind_of?(SessionCharset) ? arg : SessionCharset.new(arg.to_s)
end

Instance Method Details

#encodingObject



66
67
68
69
70
71
72
73
74
75
# File 'lib/teradata-cli/utils.rb', line 66

def encoding
  case @name
  when /UTF8/i then Encoding::UTF_8
  when /KANJISJIS_0S/i then Encoding::Windows_31J
  when /KANJIEUC_0U/i then Encoding::EUC_JP
  when /ASCII/i then Encoding::US_ASCII
  else
    raise ArgumentError, "could not convert session charset to encoding name: #{sc.inspect}"
  end
end