Class: Bag::Adres

Inherits:
Base
  • Object
show all
Defined in:
lib/bag/adres.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latitude, longitude, postcode, woonplaats, gemeente, provincie, straatnaam, huisnummer, huisletter, toevoeging) ⇒ Adres

Returns a new instance of Adres.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/bag/adres.rb', line 5

def initialize(latitude, longitude, postcode, woonplaats, gemeente, provincie, straatnaam, huisnummer, huisletter, toevoeging)
  self.latitude = latitude
  self.longitude = longitude
  self.straatnaam = straatnaam
  self.huisnummer = huisnummer
  self.huisletter = huisletter
  self.toevoeging = toevoeging
  self.postcode = postcode
  self.woonplaats = woonplaats
  self.gemeente = gemeente
  self.provincie = provincie
end

Instance Attribute Details

#gemeenteObject

Returns the value of attribute gemeente.



3
4
5
# File 'lib/bag/adres.rb', line 3

def gemeente
  @gemeente
end

#huisletterObject

Returns the value of attribute huisletter.



3
4
5
# File 'lib/bag/adres.rb', line 3

def huisletter
  @huisletter
end

#huisnummerObject

Returns the value of attribute huisnummer.



3
4
5
# File 'lib/bag/adres.rb', line 3

def huisnummer
  @huisnummer
end

#latitudeObject

Returns the value of attribute latitude.



3
4
5
# File 'lib/bag/adres.rb', line 3

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



3
4
5
# File 'lib/bag/adres.rb', line 3

def longitude
  @longitude
end

#postcodeObject

Returns the value of attribute postcode.



3
4
5
# File 'lib/bag/adres.rb', line 3

def postcode
  @postcode
end

#provincieObject

Returns the value of attribute provincie.



3
4
5
# File 'lib/bag/adres.rb', line 3

def provincie
  @provincie
end

#straatnaamObject

Returns the value of attribute straatnaam.



3
4
5
# File 'lib/bag/adres.rb', line 3

def straatnaam
  @straatnaam
end

#toevoegingObject

Returns the value of attribute toevoeging.



3
4
5
# File 'lib/bag/adres.rb', line 3

def toevoeging
  @toevoeging
end

#woonplaatsObject

Returns the value of attribute woonplaats.



3
4
5
# File 'lib/bag/adres.rb', line 3

def woonplaats
  @woonplaats
end

Class Method Details

.search(postcode, huisnummer = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bag/adres.rb', line 18

def self.search(postcode, huisnummer=nil)
  response = get("/postcodes/#{postcode}", query: huisnummer ? {huisnummer: huisnummer} : {})
  result = []
  if response.success?
    response.each do |obj|
      result << self.new(obj['latitude'], obj['longitude'], obj['postcode'], obj['woonplaats'], obj['gemeente'], obj['provincie'], obj['straatnaam'], obj['huisnummer'], obj['huisletter'], obj['toevoeging'])
    end
  elsif response.code == 404
    return nil
  else
    raise response.parsed_response['error']
  end
  result
end