Permalink
Browse files

+ service numbers use the same local format as the rest of the number…

…s by default
  • Loading branch information...
1 parent 7a40c1c commit a6fb75889b2b0ad724965f7d23038c6cb50d4244 @floere committed Nov 19, 2010
Showing with 7 additions and 3 deletions.
  1. +0 −1 lib/phony/countries/all_other.rb
  2. +4 −2 lib/phony/country.rb
  3. +3 −0 spec/lib/phony_spec.rb
@@ -51,7 +51,6 @@ def self.mapping
),
'33' => fixed(1, # France
:local_format => [2, 2, 2, 2],
- :service_local_format => [2, 2, 2, 2],
:service_ndcs => %w{8}
# :special_ndcs => {
# :service => %w{8},
View
@@ -80,15 +80,17 @@ def self.configured options = {}
def self.fixed options = {}
ndc_length = options[:ndc_length]
service_ndcs = options[:service_ndcs]
+ local_format = options[:local_format]
national_splitter = Phony::NationalSplitters::Fixed.new ndc_length
- local_splitter = Phony::LocalSplitter.instance_for options[:local_format] || [3, 2, 2]
+ local_splitter = Phony::LocalSplitter.instance_for local_format || [3, 2, 2]
national_code = Phony::NationalCode.new national_splitter, local_splitter
service_code = nil
if service_ndcs
+ service_local_format = options[:service_local_format] || local_format
service_national_splitter = Phony::NationalSplitters::Variable.new nil, :service => service_ndcs
- service_local_splitter = Phony::LocalSplitter.instance_for options[:service_local_format] || [3, 3]
+ service_local_splitter = Phony::LocalSplitter.instance_for service_local_format || [3, 3]
service_code = Phony::NationalCode.new service_national_splitter, service_local_splitter
end
View
@@ -30,6 +30,9 @@
Phony.split('6491234567').should == ['64', '9', '123', '4567']
end
+ it "should handle french service numbers" do
+ Phony.split('33812345678').should == ['33', '8', '12','34','56','78']
+ end
it "should handle swiss service numbers" do
Phony.split('41800334455').should == ['41', '800', '334', '455']
end

0 comments on commit a6fb758

Please sign in to comment.