Class: MySociety::MapIt::Postcode

Inherits:
Object
  • Object
show all
Includes:
LocalAuthorityFinder, UriToHash
Defined in:
lib/my_society/map_it.rb

Constant Summary

Constants included from LocalAuthorityFinder

LocalAuthorityFinder::LOCAL_AUTHORITY_TYPE_CODES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UriToHash

#to_hash

Methods included from LocalAuthorityFinder

#local_authority

Constructor Details

#initialize(postcode) ⇒ Postcode

Returns a new instance of Postcode.



106
107
108
# File 'lib/my_society/map_it.rb', line 106

def initialize postcode
  self.postcode = postcode
end

Instance Attribute Details

#postcodeObject

Returns the value of attribute postcode.



103
104
105
# File 'lib/my_society/map_it.rb', line 103

def postcode
  @postcode
end

Instance Method Details

#normalised_postcodeObject



110
111
112
# File 'lib/my_society/map_it.rb', line 110

def normalised_postcode
  postcode.upcase.gsub /\s+/, ''
end

#to_pointObject



118
119
120
121
# File 'lib/my_society/map_it.rb', line 118

def to_point
  h = to_hash.dup
  Point.new h['wgs84_lon'], h['wgs84_lat'], Point::SYSTEM_WGS84
end

#uriObject



114
115
116
# File 'lib/my_society/map_it.rb', line 114

def uri
  "#{MySociety::MapIt.base_url}/postcode/#{normalised_postcode}"
end