Module: MySociety::MapIt::LocalAuthorityFinder
Constant Summary collapse
- DISTRICT_TYPE_CODES =
%w( DIS LGD ).freeze
- UNITARY_TYPE_CODES =
%w( UTA MTD LBO COI ).freeze
- COUNTY_TYPE_CODES =
%w( CTY ).freeze
- COUNTY_WARD_TYPE_CODES =
%w( CED )
- PARISH_TYPE_CODES =
%w( CPC COP )
- WARD_TYPE_CODES =
%w( DIW LBW LGW MTW UTW )
Instance Method Summary collapse
- #county ⇒ Object
- #county_ward ⇒ Object
- #detect(type) ⇒ Object
- #district ⇒ Object
- #local_authority ⇒ Object
- #parish ⇒ Object
- #two_tier? ⇒ Boolean
- #unitary ⇒ Object
- #ward ⇒ Object
Instance Method Details
#county ⇒ Object
53 54 55 56 |
# File 'lib/my_society/map_it.rb', line 53 def county return if district.nil? detect(COUNTY_TYPE_CODES) end |
#county_ward ⇒ Object
58 59 60 61 |
# File 'lib/my_society/map_it.rb', line 58 def county_ward return if county.nil? detect(COUNTY_WARD_TYPE_CODES) end |
#detect(type) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/my_society/map_it.rb', line 84 def detect(type) la = to_point.to_hash.values.detect do |la| type.include? la['type'] end return if la.nil? LocalAuthority.new la rescue nil end |
#district ⇒ Object
45 46 47 |
# File 'lib/my_society/map_it.rb', line 45 def district detect(DISTRICT_TYPE_CODES) end |
#local_authority ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/my_society/map_it.rb', line 71 def if district.nil? unitary else { :district => district, :county => county } end rescue nil end |
#parish ⇒ Object
49 50 51 |
# File 'lib/my_society/map_it.rb', line 49 def parish detect(PARISH_TYPE_CODES) end |
#two_tier? ⇒ Boolean
96 97 98 |
# File 'lib/my_society/map_it.rb', line 96 def two_tier? .kind_of? Hash end |
#unitary ⇒ Object
63 64 65 |
# File 'lib/my_society/map_it.rb', line 63 def unitary detect(UNITARY_TYPE_CODES) end |
#ward ⇒ Object
67 68 69 |
# File 'lib/my_society/map_it.rb', line 67 def ward detect(WARD_TYPE_CODES) end |