class BrDanfe::XML
Public Class Methods
Source
# File lib/br_danfe/xml.rb, line 7 def initialize(xml) @xml = Nokogiri::XML(xml) end
Public Instance Methods
Source
# File lib/br_danfe/xml.rb, line 11 def [](xpath) node = @xml.css(xpath) node ? node.text : '' end
Source
# File lib/br_danfe/xml.rb, line 16 def collect(ns, tag) result = [] # With namespace begin @xml.xpath("//#{ns}:#{tag}").each do |det| result << yield(det) end rescue StandardError # Without namespace @xml.xpath("//#{tag}").each do |det| result << yield(det) end end result end
Source
# File lib/br_danfe/xml.rb, line 32 def version_is_310_or_newer? @xml.css('infNFe').attr('versao').to_s.to_f >= 3.10 end