Class: MySociety::MapIt::Postcode
- Inherits:
-
Object
- Object
- MySociety::MapIt::Postcode
- Includes:
- LocalAuthorityFinder, UriToHash
- Defined in:
- lib/my_society/map_it.rb
Constant Summary
Constants included from LocalAuthorityFinder
LocalAuthorityFinder::COUNTY_TYPE_CODES, LocalAuthorityFinder::COUNTY_WARD_TYPE_CODES, LocalAuthorityFinder::DISTRICT_TYPE_CODES, LocalAuthorityFinder::PARISH_TYPE_CODES, LocalAuthorityFinder::UNITARY_TYPE_CODES, LocalAuthorityFinder::WARD_TYPE_CODES
Instance Attribute Summary collapse
-
#postcode ⇒ Object
readonly
Returns the value of attribute postcode.
Instance Method Summary collapse
- #easting_northing ⇒ Object
-
#initialize(postcode) ⇒ Postcode
constructor
A new instance of Postcode.
- #normalised_postcode ⇒ Object
- #to_point ⇒ Object
- #uri ⇒ Object
Methods included from UriToHash
Methods included from LocalAuthorityFinder
#county, #county_ward, #detect, #district, #local_authority, #parish, #two_tier?, #unitary, #ward
Constructor Details
#initialize(postcode) ⇒ Postcode
Returns a new instance of Postcode.
175 176 177 |
# File 'lib/my_society/map_it.rb', line 175 def initialize postcode self.postcode = postcode end |
Instance Attribute Details
#postcode ⇒ Object
Returns the value of attribute postcode.
172 173 174 |
# File 'lib/my_society/map_it.rb', line 172 def postcode @postcode end |
Instance Method Details
#easting_northing ⇒ Object
192 193 194 195 196 197 198 199 200 |
# File 'lib/my_society/map_it.rb', line 192 def easting_northing h = to_hash.dup if h['coordsyst'] == "G" coordsyst = Point::SYSTEM_BRITISH_NATIONAL_GRID else h['coordsyst'] == "I" coordsyst = Point::SYSTEM_IRISH_NATIONAL_GRID end Point.new h['northing'], h['easting'], coordsyst end |
#normalised_postcode ⇒ Object
179 180 181 |
# File 'lib/my_society/map_it.rb', line 179 def normalised_postcode postcode.upcase.gsub /\s+/, '' end |
#to_point ⇒ Object
187 188 189 190 |
# File 'lib/my_society/map_it.rb', line 187 def to_point h = to_hash.dup Point.new h['wgs84_lat'], h['wgs84_lon'], Point::SYSTEM_WGS84 end |