Skip to content

Commit

Permalink
Correct belgian mobile numbers from 04xxxxxxxx to 324xxxxxxxx
Browse files Browse the repository at this point in the history
  • Loading branch information
Narnach committed Jan 8, 2010
1 parent 5591f6b commit 2e7b1a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/number_recognizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def correct
case number
when /^0[96]6*(\d{8})$/
self.number = "00316#{$1}"
when /^04(\d{8})$/
self.number = "324#{$1}"
else
return false
end
Expand Down
15 changes: 15 additions & 0 deletions spec/number_recognizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@
@nc.local_number.should == '612345678'
end

it 'should correct 0412345678 to 32412345678' do
@nc = NumberRecognizer.new('0412345678')
@nc.should_not be_valid

@nc.correct.should be_true
@nc.number.should == '32412345678'
@nc.old_number.should == '0412345678'

@nc.type.should == 'Belgian mobile'
@nc.country.should == '32'
@nc.local_number.should == '412345678'
end



describe 'valid or correct mobile' do
it 'should correct 0612345678 to 0031612345678' do
@nc = NumberRecognizer.new('0612345678')
Expand Down

0 comments on commit 2e7b1a5

Please sign in to comment.