Module: BrInvoicesPdf::Util::XmlLocate

Class Method Summary collapse

Class Method Details

.locate_element(xml, path) ⇒ Object



8
9
10
11
# File 'lib/br_invoices_pdf/util/xml_locate.rb', line 8

def locate_element(xml, path)
  element = xml.locate(path).first
  element.text if element.is_a?(Ox::Element)
end

.node_locate(element, path) ⇒ Object



17
18
19
20
# File 'lib/br_invoices_pdf/util/xml_locate.rb', line 17

def node_locate(element, path)
  value = element.nodes.first.locate(path).first
  value.text if value.is_a?(Ox::Element)
end

.root_path(xml) ⇒ Object



13
14
15
# File 'lib/br_invoices_pdf/util/xml_locate.rb', line 13

def root_path(xml)
  xml.name == 'NFe' ? 'infNFe' : 'NFe/infNFe'
end