Class: GoMaps::CEP

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

Instance Method Summary collapse

Constructor Details

#initialize(cep) ⇒ CEP

Returns a new instance of CEP.



3
4
5
6
# File 'lib/go_maps/cep.rb', line 3

def initialize(cep)
  @response = Nokogiri::XML(open("http://cep.republicavirtual.com.br/web_cep.php?cep=#{cep}"))
  raise GoMaps::AddressNotFoundException if element('resultado') == "0"
end

Instance Method Details

#cityObject



12
13
14
# File 'lib/go_maps/cep.rb', line 12

def city
  element 'cidade'
end

#streetObject



8
9
10
# File 'lib/go_maps/cep.rb', line 8

def street
  "#{element('tipo_logradouro')} #{element('logradouro')}"
end

#ufObject



16
17
18
# File 'lib/go_maps/cep.rb', line 16

def uf
  element 'uf'
end