russian_phone 0.3.2 → 0.3.3
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/russian_phone/number.rb +12 -7
- data/lib/russian_phone/version.rb +1 -1
- metadata +1 -1
data/lib/russian_phone/number.rb
CHANGED
|
@@ -63,6 +63,7 @@ module RussianPhone
|
|
|
63
63
|
def city
|
|
64
64
|
@city ||= parse(:city)
|
|
65
65
|
end
|
|
66
|
+
alias_method :area, :city
|
|
66
67
|
|
|
67
68
|
def country
|
|
68
69
|
@country ||= parse(:country)
|
|
@@ -92,17 +93,21 @@ module RussianPhone
|
|
|
92
93
|
[]
|
|
93
94
|
end
|
|
94
95
|
end
|
|
95
|
-
|
|
96
|
+
|
|
97
|
+
def formatted_area
|
|
98
|
+
area.nil? ? '' : "(#{area})"
|
|
99
|
+
end
|
|
100
|
+
|
|
96
101
|
def formatted_subscriber
|
|
97
|
-
format.join('-')
|
|
102
|
+
subscriber.nil? ? '' : format.join('-')
|
|
98
103
|
end
|
|
99
104
|
|
|
100
105
|
def full
|
|
101
106
|
if valid?
|
|
102
107
|
if free? && extra == ''
|
|
103
|
-
"8-#{
|
|
108
|
+
"8-#{area}-#{formatted_subscriber}"
|
|
104
109
|
else
|
|
105
|
-
"+#{country}
|
|
110
|
+
"+#{country} #{formatted_area} #{formatted_subscriber}#{extra == '' ? '' : ' ' + extra}"
|
|
106
111
|
end
|
|
107
112
|
else
|
|
108
113
|
''
|
|
@@ -110,15 +115,15 @@ module RussianPhone
|
|
|
110
115
|
end
|
|
111
116
|
|
|
112
117
|
def clean
|
|
113
|
-
"#{country}#{
|
|
118
|
+
"#{country}#{area}#{subscriber}"
|
|
114
119
|
end
|
|
115
120
|
|
|
116
121
|
def cell?
|
|
117
|
-
Codes.cell_codes.include?(
|
|
122
|
+
Codes.cell_codes.include?(area)
|
|
118
123
|
end
|
|
119
124
|
|
|
120
125
|
def free?
|
|
121
|
-
|
|
126
|
+
area == '800'
|
|
122
127
|
end
|
|
123
128
|
|
|
124
129
|
# alias_method(:to_s, :full)
|