Module: ConsultaSunat::ParseContent
- Defined in:
- lib/consulta_sunat/parse_content.rb
Class Method Summary collapse
Class Method Details
.clean_page(page) ⇒ Object
20 21 22 23 |
# File 'lib/consulta_sunat/parse_content.rb', line 20 def self.clean_page page page.encode!('UTF-8', 'iso-8859-1') page.gsub(/\r\n/, "\n") end |
.parse_page(page) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/consulta_sunat/parse_content.rb', line 4 def self.parse_page page page = clean_page page file_path = File.join(File.dirname(__FILE__), "sunat_match_data.yaml") sunat_match_data = YAML.load_file(file_path) sunat_data = {} sunat_match_data.each do |key, expr| sunat_data[key] = if result = page.match(expr) result[1] else "-" end end return sunat_data end |