Module: ZhongwenTools::Script

Defined in:
lib/zhongwen_tools/script.rb

Constant Summary collapse

ZH_TYPES =
{
  :zht => [0],
  :zhs => [1],
  :zhtw => [2,0],
  :zhhk => [3,0],
  :zhcn => [4,1]
}
ZH_CONVERSION_TABLE =
[]

Class Method Summary collapse

Class Method Details

.to_zhs(str, type) ⇒ Object



13
14
15
16
17
18
# File 'lib/zhongwen_tools/script.rb', line 13

def self.to_zhs(str, type)
  type = type.to_sym
  fail ArgumentError unless [:zhs, :zhcn].include? type

  convert(type, str)
end

.to_zht(str, type) ⇒ Object



20
21
22
23
24
25
# File 'lib/zhongwen_tools/script.rb', line 20

def self.to_zht(str, type)
  type = type.to_sym
  fail ArgumentError unless [:zht, :zhtw, :zhhk].include? type

  convert(type, str)
end

.zhs?(str) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/zhongwen_tools/script.rb', line 9

def self.zhs?(str)
  str == convert(:zhs, str)
end

.zht?(str) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/zhongwen_tools/script.rb', line 5

def self.zht?(str)
  str == convert(:zht, str) ||  str == convert(:zhhk, str)
end