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.
Files changed (3) hide show
  1. data/lib/area.rb +15 -2
  2. data/readme.md +8 -2
  3. 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
- r = Regexp.new("#{self}")
11
- return row[1] if r.match(row[0])
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 extract a region in the United States from an area code. Area uses public data and does not rely on any external services or have any dependencies.
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: `646.to_region #=> NY`
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: area
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: