Class: CBETA::HTMLToText

Inherits:
Object
  • Object
show all
Defined in:
lib/cbeta/html_to_text.rb

Overview

將 CBETA HTML 轉為 純文字(含行首資訊)

Example:

h2t = CBETA::HTMLToText.new('/temp/cbeta-html', '/temp/cbeta-text')
h2t.convert("T01")  # 轉換大正藏第一冊

Instance Method Summary collapse

Constructor Details

#initialize(html_root, out_root) ⇒ HTMLToText

Returns a new instance of HTMLToText.

Parameters:

  • html_root (String)

    來源 HTML 路徑

  • out_root (String)

    輸出路徑



13
14
15
16
# File 'lib/cbeta/html_to_text.rb', line 13

def initialize(html_root, out_root)
  @html_root = html_root
  @out_root = out_root
end

Instance Method Details

#convert(arg) ⇒ Object

Examples:

convert("T01")

Parameters:

  • arg (String)

    要執行轉換的冊數



21
22
23
24
25
26
# File 'lib/cbeta/html_to_text.rb', line 21

def convert(arg)
  @dirty = false
  @vol = arg.upcase
  @corpus = @vol[0]
  handle_vol
end