asseinfo/br_danfe

View on GitHub
lib/br_danfe/cce_lib/nfe_key.rb

Summary

Maintainability
A
1 hr
Test Coverage
A
100%
module BrDanfe
  module CceLib
    class NfeKey
      def initialize(pdf, xml)
        @pdf = pdf
        @xml = Nokogiri::XML(xml)
      end

      def render
        @pdf.box(height: 36) do
          @pdf.text I18n.t('cce.key'), size: 8, style: :bold
          @pdf.text nfe_key, pad: 5
        end
      end

      private

      def nfe_key
        node = @xml.css('procEventoNFe > evento > infEvento > chNFe')
        node ? node.text : ''
      end
    end
  end
end