-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathURY.coffee
44 lines (37 loc) · 1.14 KB
/
URY.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
# For more info check:
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Uruguay
# https://www.numberingplans.com/?page=dialling&sub=areacodes
# http://www.howtocallabroad.com/uruguay/
class Uruguay
constructor: ->
@countryName = "Uruguay"
@countryNameAbbr = "URY"
@countryCode = '598'
@regex = /^(?:(?:\+|)598|)(?:0|)(?:[249]\d{7})$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode =
[
'2', '4', '9' # 9 is mobile
]
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
if (ndc.length + withoutNDC.length) is 8
if ndc is '9'
phone.isMobile = true
phone.nationalDestinationCode = ''
phone.number = withoutCountryCode
return phone
splitNumber: (number) =>
if number.length is 7
return Phone.compact number.split(/(\d{3})(\d{4})/)
else if number.length is 8
return Phone.compact number.split(/(\d{4})(\d{4})/)
return [number]
# register
uruguay = new Uruguay()
Phone.countries['598'] = uruguay
# exports
module.exports = uruguay