Class: PinyinResource

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/pinyin_resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePinyinResource

Returns a new instance of PinyinResource.



6
7
8
9
10
11
12
# File 'lib/pinyin_resource.rb', line 6

def initialize
  @dict = {  };
  File.open(File.join(File.dirname(__FILE__), "..", "asserts", "unicode_to_hanyu_pinyin.txt")).each_line do |line|
    code, pinyin_raw = line.split
    @dict[code.to_i(16)] = pinyin_raw[1..-2].split(",")
  end
end

Instance Attribute Details

#dictObject

Returns the value of attribute dict.



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

def dict
  @dict
end