Class: UdiseSchoolReportReader::SchoolReportParser

Inherits:
Object
  • Object
show all
Defined in:
lib/udise_school_report_reader/school_report_parser.rb

Defined Under Namespace

Classes: OutputPaths

Class Method Summary collapse

Class Method Details

.extract_to_text(pdf_path, output_dir = nil, write_files = false) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/udise_school_report_reader/school_report_parser.rb', line 9

def self.extract_to_text(pdf_path, output_dir = nil, write_files = false)
  raise ArgumentError, "PDF file not found" unless File.exist?(pdf_path)

  # Extract all data first
  extracted_data = extract_data(pdf_path)
  
  # Write files if requested
  write_output_files(pdf_path, extracted_data, output_dir) if write_files
  
  # Return the YAML data
  extracted_data[:yaml_data]
end