Class: LocalAuthority::LocalAuthority
- Inherits:
-
Object
- Object
- LocalAuthority::LocalAuthority
- Defined in:
- lib/local_authority.rb
Constant Summary collapse
- DB_FILE =
File.join File.dirname(__FILE__), '..', 'db', 'local_authorities.csv'
- DB =
CSV.new File.read(DB_FILE), :headers => :first_row
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(attributes) ⇒ LocalAuthority
constructor
A new instance of LocalAuthority.
- #map_it_id ⇒ Object
- #name ⇒ Object
- #phone_number ⇒ Object
- #website ⇒ Object
Constructor Details
#initialize(attributes) ⇒ LocalAuthority
Returns a new instance of LocalAuthority.
30 31 32 |
# File 'lib/local_authority.rb', line 30 def initialize attributes self.attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
27 28 29 |
# File 'lib/local_authority.rb', line 27 def attributes @attributes end |
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/local_authority.rb', line 10 def self.all @all ||= DB.map { |row| new row.to_hash } end |
.find_by_map_it_id(id) ⇒ Object
14 15 16 17 18 |
# File 'lib/local_authority.rb', line 14 def self.find_by_map_it_id id all.detect { |la| la.map_it_id =~ /\/#{id}$/ } end |
.find_by_postcode(postcode) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/local_authority.rb', line 20 def self.find_by_postcode postcode p = MySociety::MapIt::Postcode.new postcode la = p. return if la.nil? find_by_map_it_id la.id end |
Instance Method Details
#address ⇒ Object
46 47 48 |
# File 'lib/local_authority.rb', line 46 def address attributes['Address'] end |
#map_it_id ⇒ Object
50 51 52 |
# File 'lib/local_authority.rb', line 50 def map_it_id attributes['MapIt ID'] end |
#name ⇒ Object
38 39 40 |
# File 'lib/local_authority.rb', line 38 def name attributes['Name'] end |
#phone_number ⇒ Object
42 43 44 |
# File 'lib/local_authority.rb', line 42 def phone_number attributes['Phone Number'] end |
#website ⇒ Object
34 35 36 |
# File 'lib/local_authority.rb', line 34 def website attributes['Website'] end |