Class: CBETA::P5aToText
- Inherits:
-
Object
- Object
- CBETA::P5aToText
- Defined in:
- lib/cbeta/p5a_to_text.rb
Overview
Convert CBETA XML P5a to Text
CBETA XML P5a 可由此取得: https://github.com/cbeta-git/xml-p5a
Instance Method Summary collapse
-
#convert(target = nil) ⇒ Object
將 CBETA XML P5a 轉為 Text.
-
#initialize(xml_root, output_root) ⇒ P5aToText
constructor
A new instance of P5aToText.
Constructor Details
#initialize(xml_root, output_root) ⇒ P5aToText
Returns a new instance of P5aToText.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cbeta/p5a_to_text.rb', line 15 def initialize(xml_root, output_root) @xml_root = xml_root @output_root = output_root @cbeta = CBETA.new @gaijis = CBETA::Gaiji.new # 載入 unicode 1.1 字集列表 fn = File.join(File.dirname(__FILE__), 'unicode-1.1.json') json = File.read(fn) @unicode1 = JSON.parse(json) end |
Instance Method Details
#convert(target = nil) ⇒ Object
將 CBETA XML P5a 轉為 Text
T 是大正藏的 ID, CBETA 的藏經 ID 系統請參考: http://www.cbeta.org/format/id.php
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cbeta/p5a_to_text.rb', line 45 def convert(target=nil) return convert_all if target.nil? arg = target.upcase if arg.size == 1 handle_collection(arg) else if arg.include? '..' arg.match(/^([^\.]+?)\.\.([^\.]+)$/) { handle_vols($1, $2) } else handle_vol(arg) end end end |