Class: GdsApi::Mapit

Inherits:
Base
  • Object
show all
Defined in:
lib/gds_api/mapit.rb

Defined Under Namespace

Classes: Location

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#client, #create_client, #get_list, #initialize, #url_for_slug

Constructor Details

This class inherits a constructor from GdsApi::Base

Instance Method Details

#area_for_code(code_type, code) ⇒ Object


14
15
16
# File 'lib/gds_api/mapit.rb', line 14

def area_for_code(code_type, code)
  get_json("#{base_url}/code/#{code_type}/#{code}.json")
end

#areas_for_type(type) ⇒ Object


10
11
12
# File 'lib/gds_api/mapit.rb', line 10

def areas_for_type(type)
  get_json("#{base_url}/areas/#{type}.json")
end

#location_for_postcode(postcode) ⇒ Object


5
6
7
8
# File 'lib/gds_api/mapit.rb', line 5

def location_for_postcode(postcode)
  response = get_json("#{base_url}/postcode/#{CGI.escape postcode}.json")
  Location.new(response) unless response.nil?
end