lib/russian_phone/number.rb in russian_phone-0.3.2 vs lib/russian_phone/number.rb in russian_phone-0.3.3
- old
+ new
@@ -61,10 +61,11 @@
end
def city
@city ||= parse(:city)
end
+ alias_method :area, :city
def country
@country ||= parse(:country)
end
@@ -90,36 +91,40 @@
split([1, 2, 2], subscriber)
else
[]
end
end
-
+
+ def formatted_area
+ area.nil? ? '' : "(#{area})"
+ end
+
def formatted_subscriber
- format.join('-')
+ subscriber.nil? ? '' : format.join('-')
end
def full
if valid?
if free? && extra == ''
- "8-#{city}-#{formatted_subscriber}"
+ "8-#{area}-#{formatted_subscriber}"
else
- "+#{country} (#{city}) #{formatted_subscriber}#{extra == '' ? '' : ' ' + extra}"
+ "+#{country} #{formatted_area} #{formatted_subscriber}#{extra == '' ? '' : ' ' + extra}"
end
else
''
end
end
def clean
- "#{country}#{city}#{subscriber}"
+ "#{country}#{area}#{subscriber}"
end
def cell?
- Codes.cell_codes.include?(city)
+ Codes.cell_codes.include?(area)
end
def free?
- city == '800'
+ area == '800'
end
# alias_method(:to_s, :full)
# alias_method(:inspect, :full)
\ No newline at end of file