Skip to content

Commit

Permalink
Improve Japanese telephone number.
Browse files Browse the repository at this point in the history
  • Loading branch information
KURASAWA Nozomu committed May 26, 2015
1 parent deb486e commit 271f37f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/phony/countries/japan.rb
Expand Up @@ -402,13 +402,14 @@
Phony.define do
country '81',
trunk('0') |
one_of('20', '50', '60', '70', '90') >> split(4,4) | # mobile, VoIP telephony
one_of(ndcs_with_5_subscriber_numbers) >> split(1,4) |
one_of(ndcs_with_6_subscriber_numbers) >> split(2,4) |
one_of(%w(120 800)) >> split(3,3) | # freephone
one_of(ndcs_with_7_subscriber_numbers) >> split(3,4) |
one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
one_of('20', '50', '60', '70', '90') >> split(4,4) | # mobile, VoIP telephony
# TODO: 91(NDC) N(S)N length: 5-13 - Non-geographic number (Direct subscriber telephone service (legacy))
fixed(2) >> split(4,4),
:local_space => :-
:local_space => :- ,
:space => :-
end
12 changes: 9 additions & 3 deletions spec/lib/phony/countries_spec.rb
Expand Up @@ -373,12 +373,18 @@ def self.it_splits number, expected
it_splits '390471811353', ['39', '0471', '811', '353'] # Bolzano
end
describe 'Japan' do
it_splits '81312345678', %w(81 3 1234 5678)
it_splits '81120123456', %w(81 120 123 456)
it_splits '81312345678', %w(81 3 1234 5678) # Tokyo
it_splits '81612345678', %w(81 6 1234 5678) # Osaka
it_splits '81120123456', %w(81 120 123 456) # Freephone
it_splits '81111234567', %w(81 11 123 4567)
it_splits '81123123456', %w(81 123 12 3456)
it_splits '81126712345', %w(81 1267 1 2345)
it_splits '819012345678', %w(81 90 1234 5678)
it_splits '812012345678', %w(81 20 1234 5678) # Pager(Calling Party Pay)
it_splits '815012345678', %w(81 50 1234 5678) # IP Telephone
it_splits '816012345678', %w(81 60 1234 5678) # UPT
it_splits '817012345678', %w(81 70 1234 5678) # PHS
it_splits '818012345678', %w(81 80 1234 5678) # Cellular
it_splits '819012345678', %w(81 90 1234 5678) # Cellular
end
describe 'Kenya' do
it_splits '254201234567', ['254', '20', '1234567'] # Nairobi
Expand Down

0 comments on commit 271f37f

Please sign in to comment.