itu_codes 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Mani Tadayon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,54 @@
1
+ # ItuCodes relies on the excellent Carmen library:
2
+ # http://github.com/jim/carmen/tree/master
3
+
4
+ # sample usage:
5
+
6
+ ItuCodes.valid_code? 8392813 # => false
7
+
8
+ ItuCodes.valid_code? 7 # => true
9
+
10
+ ItuCodes.parse_code 1818 # => 1
11
+
12
+ ItuCodes.parse_code 822 # => "82"
13
+
14
+ ItuCodes.parse_code 4 # => nil
15
+
16
+ ItuCodes.find("France") # => "33"
17
+
18
+ ItuCodes.find("995") # => "Georgia"
19
+
20
+ ItuCodes.find("Erewhon") # => nil
21
+
22
+ ItuCodes.find("123123995") # => nil
23
+
24
+ # Despite the same 1st digit,
25
+ # these are for different
26
+ # countries ...
27
+ ItuCodes.compatriots? 822, 811 # => false
28
+
29
+ # ... but these are for
30
+ # the same country ...
31
+ ItuCodes.compatriots? 122, 111 # => true
32
+
33
+ # =====================================================
34
+ # = Using 2-letter ISO country codes is most reliable =
35
+ # =====================================================
36
+ # ... and then there's the
37
+ # North American 'situation' ...
38
+ ItuCodes.compatriots? 1264, 1818 # => false
39
+
40
+ # Convert from and to ISO 2-letter country codes:
41
+ ItuCodes.iso2itu('US') # => "1"
42
+
43
+ ItuCodes.itu2iso('1')
44
+ # => ["US", "CA", "AS", "AI", "AG", "BS", "BB", "BM", "KY", "DM", "DO", "GD", "GU", "JM", "MS", "MP", "KN", "LC", "VC", "TT", "TC"]
45
+
46
+ # Mexico
47
+ # ISO 3361 code : MX
48
+ # ITU code : 52
49
+ ItuCodes.iso2itu('MX') # => "52"
50
+
51
+ # Georgia
52
+ # ISO 3361 code : GE
53
+ # ITU code : 995
54
+ ItuCodes.itu2iso('995') # => ["GE"]
@@ -0,0 +1,3 @@
1
+ module ItuCodes
2
+ VERSION = "0.3"
3
+ end