Class: CBETA::Gaiji
- Inherits:
-
Object
- Object
- CBETA::Gaiji
- Defined in:
- lib/cbeta/gaiji.rb
Overview
存取 CBETA 缺字資料庫
Instance Method Summary collapse
-
#[](cb) ⇒ Hash{String => Strin, Array<String>}?
傳入,傳回 hash 缺字資訊.
-
#initialize ⇒ Gaiji
constructor
載入 CBETA 缺字資料庫.
-
#zhuyin(cb) ⇒ Array<String>
傳入缺字 CB 碼,傳回注音 array.
Constructor Details
#initialize ⇒ Gaiji
載入 CBETA 缺字資料庫
6 7 8 9 |
# File 'lib/cbeta/gaiji.rb', line 6 def initialize() fn = File.join(File.dirname(__FILE__), 'gaiji.json') @gaijis = JSON.parse(File.read(fn)) end |
Instance Method Details
#[](cb) ⇒ Hash{String => Strin, Array<String>}?
傳入,傳回 hash 缺字資訊
Return:
{
"zzs": "[得-彳]",
"unicode": "3775",
"unicode-char": "㝵",
"zhuyin": [ "ㄉㄜˊ", "ㄞˋ" ]
}
28 29 30 |
# File 'lib/cbeta/gaiji.rb', line 28 def [](cb) @gaijis[cb] end |
#zhuyin(cb) ⇒ Array<String>
傳入缺字 CB 碼,傳回注音 array
40 41 42 43 |
# File 'lib/cbeta/gaiji.rb', line 40 def (cb) return nil unless @gaijis.key? cb @gaijis[cb]['zhuyin'] end |