Class: Correios

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

Class Method Summary collapse

Class Method Details

.encomenda(numero, url = @url_rastreamento) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/correios.rb', line 11

def self.encomenda(numero, url=@url_rastreamento)
  html = Hpricot(open("#{url}#{numero}"))
  encomenda = Encomenda.new(numero)
  
  pula_tr = true
  (html/"tr").each do |tr|
     status = nil
     status = self.parse_tr(encomenda, tr) if not pula_tr
     encomenda << status if not status.nil?
     pula_tr = false
  end
  return encomenda
end