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 可由此取得: github.com/cbeta-git/xml-p5a
Instance Method Summary collapse
-
#convert(target = nil) ⇒ Object
將 CBETA XML P5a 轉為 Text.
-
#initialize(xml_root, output_root, opts = {}) ⇒ P5aToText
constructor
A new instance of P5aToText.
Constructor Details
#initialize(xml_root, output_root, opts = {}) ⇒ P5aToText
Returns a new instance of P5aToText.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cbeta/p5a_to_text.rb', line 31 def initialize(xml_root, output_root, opts={}) @xml_root = xml_root @output_root = output_root @settings = { format: nil, encoding: 'UTF-8', gaiji: 'default' } @settings.merge!(opts) @cbeta = CBETA.new @gaijis = CBETA::Gaiji.new end |
Instance Method Details
#convert(target = nil) ⇒ Object
將 CBETA XML P5a 轉為 Text
T 是大正藏的 ID, CBETA 的藏經 ID 系統請參考: www.cbeta.org/format/id.php
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cbeta/p5a_to_text.rb', line 69 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 |