Class: LocalAuthority::LocalAuthority

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#attributesObject

Returns the value of attribute attributes.



19
20
21
# File 'lib/local_authority.rb', line 19

def attributes
  @attributes
end

Class Method Details

.allObject



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

#addressObject



38
39
40
# File 'lib/local_authority.rb', line 38

def address
  attributes['Address']
end

#map_it_idObject



42
43
44
# File 'lib/local_authority.rb', line 42

def map_it_id
  attributes['MapIt ID']
end

#nameObject



30
31
32
# File 'lib/local_authority.rb', line 30

def name
  attributes['Name']
end

#phone_numberObject



34
35
36
# File 'lib/local_authority.rb', line 34

def phone_number
  attributes['Phone Number']
end

#websiteObject



26
27
28
# File 'lib/local_authority.rb', line 26

def website
  attributes['Website']
end