class NFe::EntidadeNFe
Public Class Methods
nfe_attrs()
click to toggle source
# File lib/nfe/entidades/entidade_nfe.rb, line 29 def nfe_attrs roxml_attrs.map(&attr_name) end
xml_accessor(*attrs)
click to toggle source
# File lib/nfe/entidades/entidade_nfe.rb, line 24 def xml_accessor(*attrs) attr_accessor *attrs # super(*attrs) end
Also aliased as: nfe_attr
Public Instance Methods
nfe_attributes()
click to toggle source
# File lib/nfe/entidades/entidade_nfe.rb, line 34 def nfe_attributes self.class.nfe_attrs end
serialize(params)
click to toggle source
def to_s
self.respond_to? :to_nfe ? to_nfe : super
end
# File lib/nfe/entidades/entidade_nfe.rb, line 61 def serialize(params) params.each do |key, value| send("#{key}=", value) if respond_to?(key) end end
to_nfe()
click to toggle source
# File lib/nfe/entidades/entidade_nfe.rb, line 50 def to_nfe #depois fazer o teste com REXML doc = Nokogiri::XML::Document.new doc.root = to_xml doc.serialize end
to_nfe_xml(file)
click to toggle source
# File lib/nfe/entidades/entidade_nfe.rb, line 38 def to_nfe_xml(file) #entidade = EntidadeNFe.from_xml(File.read(File.expand_path('example-user.xml', File.dirname(__FILE__)))) #entidade = NFe::EntidadeNFe.from_xml(File.read(File.expand_path(file, File.dirname(__FILE__)))) entidade = Nokogiri::XML(File.open(file)) doc = Nokogiri::XML::Document.new doc.root = self.to_xml # open("entidade_nfe.xml", 'w') do |file| # file << doc.serialize # end puts ">>>>>> #{doc.root.to_s}" end
to_xml(xml)
click to toggle source
# File lib/nfe/entidades/entidade_nfe.rb, line 75 def to_xml(xml) hash = '' xml.children.each do |i| hash << "<#{i.name}>#{i.text}</#{i.name}>" end hash end
xml_to_hash(xml)
click to toggle source
# File lib/nfe/entidades/entidade_nfe.rb, line 67 def xml_to_hash(xml) hash = {} xml.children.each do |i| hash.store(i.name, i.text) end hash end