Top Level Namespace

Defined Under Namespace

Modules: Analects Classes: CJKChar, CJKString, Cedict, CreateCedictTable, PopulateCedictTable

Instance Method Summary collapse

Instance Method Details

#CJKChar(str) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cjk_string.rb', line 35

def CJKChar(str)
  return str if str.is_a? CJKChar

  if str.length > 1
    if str =~ /^(U\+)?([0-9A-Fa-f]+)/
      str = [$2].pack('U')
    else
      raise ArgumentError, 'CJKChar must have length one'
    end
  end

  CJKChar.new(str)
end

#CJKString(str) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/cjk_string.rb', line 49

def CJKString(str)
  if str.is_a? CJKString
    return str
  elsif str.respond_to? :to_cjk
    str = str.to_cjk
  end
  CJKString.new(str.freeze)
end