Method: CBETA.linehead_to_xml_file_path

Defined in:
lib/cbeta.rb

.linehead_to_xml_file_path(linehead) ⇒ String

由 行首資訊 取得 XML檔相對路徑

Parameters:

  • linehead (String)

    行首資訊, 例如 “GA009n0008_p0003a01”

Returns:

  • (String)

    XML檔相對路徑,例如 “GA/GA009/GA009n0008.xml”



60
61
62
63
64
65
66
# File 'lib/cbeta.rb', line 60

def self.linehead_to_xml_file_path(linehead)
  if m = linehead.match(/^(?<work>(?<vol>(?<canon>#{CANON})\d+)n\d+[a-zA-Z]?).*$/)
    File.join(m[:canon], m[:vol], m[:work]+'.xml')
  else
    nil
  end
end