From 2e7b1a5938d2ea7fc9ef673190f5baa85d7ea8df Mon Sep 17 00:00:00 2001 From: Wes Oldenbeuving Date: Fri, 8 Jan 2010 14:34:10 +0100 Subject: [PATCH] Correct belgian mobile numbers from 04xxxxxxxx to 324xxxxxxxx --- lib/number_recognizer.rb | 2 ++ spec/number_recognizer_spec.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/number_recognizer.rb b/lib/number_recognizer.rb index 91a529a..68f9db2 100644 --- a/lib/number_recognizer.rb +++ b/lib/number_recognizer.rb @@ -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 diff --git a/spec/number_recognizer_spec.rb b/spec/number_recognizer_spec.rb index cdc9eb0..21404fc 100644 --- a/spec/number_recognizer_spec.rb +++ b/spec/number_recognizer_spec.rb @@ -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')