class BrDanfe::XML
Public Class Methods
new(xml)
click to toggle source
# File lib/br_danfe/xml.rb, line 7 def initialize(xml) @xml = Nokogiri::XML(xml) end
Public Instance Methods
[](xpath)
click to toggle source
# File lib/br_danfe/xml.rb, line 11 def [](xpath) node = @xml.css(xpath) node ? node.text : '' end
collect(ns, tag) { |det| ... }
click to toggle 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
css(xpath)
click to toggle source
# File lib/br_danfe/xml.rb, line 3 def css(xpath) @xml.css(xpath) end
version_is_310_or_newer?()
click to toggle 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