module BrInvoicesPdf::Cfe::Parser::ProductsData

Constants

FIELDS

Public Instance Methods

execute(xml) click to toggle source
# File lib/br_invoices_pdf/cfe/parser/products_data.rb, line 15
def execute(xml)
  node_products = xml.locate('infCFe/det')
  products_params(node_products) if node_products
end
product_by(element) click to toggle source
# File lib/br_invoices_pdf/cfe/parser/products_data.rb, line 25
def product_by(element)
  FIELDS
    .map do |(key, field)|
    [key, node_locate(element, field).force_encoding('windows-1252')
                                     .force_encoding('UTF-8')
                                     .encode('UTF-8')]
  end
    .to_h
end
products_params(node_products) click to toggle source
# File lib/br_invoices_pdf/cfe/parser/products_data.rb, line 20
def products_params(node_products)
  node_products.map(&method(:product_by))
end