local_authority 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module LocalAuthority
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,46 @@
1
1
  require "local_authority/version"
2
+ require "csv"
2
3
 
3
4
  module LocalAuthority
4
- # Your code goes here...
5
+ class LocalAuthority
6
+ DB_FILE = File.join File.dirname(__FILE__), '..', 'db', 'local_authorities.csv'
7
+ DB = CSV.new File.read(DB_FILE), :headers => :first_row
8
+
9
+ def self.all
10
+ @all ||= DB.map { |row| new row.to_hash }
11
+ end
12
+
13
+ def self.find_by_map_it_id id
14
+ all.detect { |la|
15
+ la.map_it_id =~ /\/#{id}$/
16
+ }
17
+ end
18
+
19
+ attr_accessor :attributes
20
+ private :attributes=
21
+
22
+ def initialize attributes
23
+ self.attributes = attributes
24
+ end
25
+
26
+ def website
27
+ attributes['Website']
28
+ end
29
+
30
+ def name
31
+ attributes['Name']
32
+ end
33
+
34
+ def phone_number
35
+ attributes['Phone Number']
36
+ end
37
+
38
+ def address
39
+ attributes['Address']
40
+ end
41
+
42
+ def map_it_id
43
+ attributes['MapIt ID']
44
+ end
45
+ end
5
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local_authority
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: -640929273992394341
92
+ hash: -2147464046989422043
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  segments:
100
100
  - 0
101
- hash: -640929273992394341
101
+ hash: -2147464046989422043
102
102
  requirements: []
103
103
  rubyforge_project:
104
104
  rubygems_version: 1.8.24