Class: CBETA::P5aChecker
- Inherits:
-
Object
- Object
- CBETA::P5aChecker
- Includes:
- CbetaShare
- Defined in:
- lib/cbeta/p5a_checker.rb
Overview
檢查 CBETA XML P5a
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(xml_root: nil, figures: nil, log: nil) ⇒ P5aChecker
constructor
A new instance of P5aChecker.
Methods included from CbetaShare
Constructor Details
#initialize(xml_root: nil, figures: nil, log: nil) ⇒ P5aChecker
Returns a new instance of P5aChecker.
8 9 10 11 12 13 |
# File 'lib/cbeta/p5a_checker.rb', line 8 def initialize(xml_root: nil, figures: nil, log: nil) @gaijis = CBETA::Gaiji.new @xml_root = xml_root @figures = figures @log = log end |
Instance Method Details
#check ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cbeta/p5a_checker.rb', line 15 def check @errors = '' @g_errors = {} puts "xml: #{@xml_root}" each_canon(@xml_root) do |c| @canon = c path = File.join(@xml_root, @canon) handle_canon(path) end @g_errors.keys.sort.each do |k| s = @g_errors[k].to_a.join(',') @errors << "#{k} 無缺字資料,出現於:#{s}\n" end if @errors.empty? puts "檢查完成,未發現錯誤。" elsif @log.nil? puts "\n發現錯誤:" puts @errors else File.write(@log, @errors) puts "\n發現錯誤,請查看 #{@log}" end end |