Class: Correios::Frete::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/correios/frete/parser.rb

Instance Method Summary collapse

Instance Method Details

#servicos(xml) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/correios/frete/parser.rb', line 7

def servicos(xml)
  servicos = {}
  xml = xml.encode("UTF-8", "ISO-8859-1")

  Nokogiri::XML(xml).root.elements.each do |element|
    servico = Correios::Frete::Servico.new.parse(element.to_xml)
    servicos[servico.tipo] = servico
  end

  servicos
end