module ConsultaSunat::ParseContent
Public Class Methods
clean_page(page)
click to toggle source
# 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)
click to toggle source
# 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