area 0.1.0 → 0.2.0
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/lib/area.rb +15 -2
- data/readme.md +8 -2
- metadata +1 -1
data/lib/area.rb
CHANGED
@@ -7,8 +7,21 @@ end
|
|
7
7
|
class Integer
|
8
8
|
def to_region
|
9
9
|
Area::DATA.each do |row|
|
10
|
-
|
11
|
-
|
10
|
+
if row.first == self.to_s
|
11
|
+
return row.last
|
12
|
+
end
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
16
|
+
|
17
|
+
class String
|
18
|
+
def to_area
|
19
|
+
@area_codes = []
|
20
|
+
Area::DATA.each do |row|
|
21
|
+
if row[1] == self
|
22
|
+
@area_codes.push(row.first)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
@area_codes
|
26
|
+
end
|
27
|
+
end
|
data/readme.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
# Area
|
2
2
|
|
3
|
-
Hi. This gem allows you to
|
3
|
+
Hi. This gem allows you to convert a region in the United States to an area code and vice versa. Area uses public data and does not rely on any external services or have any dependencies.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
7
|
In your gemfile: `gem 'area'`
|
8
8
|
|
9
|
-
In your code:
|
9
|
+
In your code:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
646.to_region #=> NY
|
13
|
+
"AK".to_area #=> ["907"]
|
14
|
+
"CT".to_area #=> ["203", "860"]
|
15
|
+
```
|
10
16
|
|
11
17
|
### Testing and Contributing
|
12
18
|
|