postcode 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/databases/database.uk.txt +8338 -0
- data/lib/postcode.rb +1 -0
- data/lib/postcode/uk.rb +16 -7
- metadata +13 -2
data/lib/postcode.rb
CHANGED
data/lib/postcode/uk.rb
CHANGED
@@ -1,13 +1,22 @@
|
|
1
1
|
module PostCode
|
2
2
|
class UK
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :outward, :inward, :latitude, :longitude
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
self.
|
5
|
+
def initialize(outward, inward, latitude, longitude)
|
6
|
+
self.outward = outward
|
7
|
+
self.inward = inward
|
7
8
|
self.latitude = latitude
|
8
9
|
self.longitude = longitude
|
9
10
|
end
|
10
11
|
|
12
|
+
def unit
|
13
|
+
"#{outward} #{inward}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
unit
|
18
|
+
end
|
19
|
+
|
11
20
|
class << self
|
12
21
|
def database=(path)
|
13
22
|
@database = FasterCSV.read(path, :col_sep => " ")
|
@@ -22,12 +31,12 @@ module PostCode
|
|
22
31
|
end
|
23
32
|
|
24
33
|
def lookup(postcode)
|
25
|
-
postcode.gsub!(/\s+/, "")
|
34
|
+
postcode.gsub!(/\s+/, "").downcase!
|
26
35
|
|
27
|
-
data =
|
36
|
+
data = database.select {|row| row if "#{row[2]}#{row[3]}".downcase == postcode }.first
|
28
37
|
|
29
|
-
if data
|
30
|
-
self.new(
|
38
|
+
if data
|
39
|
+
self.new(data[2], data[3], data[0], data[1])
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Bartholomew
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
25
35
|
description: ""
|
26
36
|
email: Stephen Bartholomew
|
27
37
|
executables: []
|
@@ -34,13 +44,14 @@ files:
|
|
34
44
|
- README
|
35
45
|
- Rakefile
|
36
46
|
- VERSION
|
47
|
+
- databases/database.uk.txt
|
37
48
|
- lib/postcode.rb
|
38
49
|
- lib/postcode/uk.rb
|
39
50
|
- spec/fixtures/database.uk.txt
|
40
51
|
- spec/postcode_spec.rb
|
41
52
|
- spec/spec.opts
|
42
53
|
has_rdoc: true
|
43
|
-
homepage: http://github.com/curve21/
|
54
|
+
homepage: http://github.com/curve21/postcode
|
44
55
|
licenses: []
|
45
56
|
|
46
57
|
post_install_message:
|