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.
22 23 24 |
# File 'lib/local_authority.rb', line 22 def initialize attributes self.attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
19 20 21 |
# File 'lib/local_authority.rb', line 19 def attributes @attributes end |
Class Method Details
.all ⇒ Object
9 10 11 |
# File 'lib/local_authority.rb', line 9 def self.all @all ||= DB.map { |row| new row.to_hash } end |
.find_by_map_it_id(id) ⇒ Object
13 14 15 16 17 |
# File 'lib/local_authority.rb', line 13 def self.find_by_map_it_id id all.detect { |la| la.map_it_id =~ /\/#{id}$/ } end |
Instance Method Details
#address ⇒ Object
38 39 40 |
# File 'lib/local_authority.rb', line 38 def address attributes['Address'] end |
#map_it_id ⇒ Object
42 43 44 |
# File 'lib/local_authority.rb', line 42 def map_it_id attributes['MapIt ID'] end |
#name ⇒ Object
30 31 32 |
# File 'lib/local_authority.rb', line 30 def name attributes['Name'] end |
#phone_number ⇒ Object
34 35 36 |
# File 'lib/local_authority.rb', line 34 def phone_number attributes['Phone Number'] end |
#website ⇒ Object
26 27 28 |
# File 'lib/local_authority.rb', line 26 def website attributes['Website'] end |