Class: PostCode

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/postcode_local.rb

Constant Summary collapse

@@url =
"https://viacep.com.br/ws"
@@header =
{"Content-Type" => "application/json"}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = @@url, header = @@header) ⇒ PostCode

Returns a new instance of PostCode.



11
12
13
14
# File 'lib/postcode_local.rb', line 11

def initialize(url=@@url, header=@@header)
  @url = url
  @header = header
end

Instance Attribute Details

#headerObject

Returns the value of attribute header.



6
7
8
# File 'lib/postcode_local.rb', line 6

def header
  @header
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/postcode_local.rb', line 6

def url
  @url
end

Instance Method Details

#get(url = @url, header = @header, postcode) ⇒ Object



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

def get(url=@url, header=@header, postcode)
  self.class.get("#{url}/#{postcode}/json/", :header => header)
end