msisdn 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/msisdn.rb +6 -1
  2. data/test/test_msisdn.rb +20 -0
  3. metadata +2 -2
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module MsisdnGem
5
- VERSION = "0.0.3"
5
+ VERSION = "0.0.4"
6
6
  end
7
7
 
8
8
  class Msisdn
@@ -26,6 +26,11 @@ class Msisdn
26
26
  return nil if @country_code.nil?
27
27
  "#{@country_code}#{@network}#{@subscriber}"
28
28
  end
29
+
30
+ def valid?
31
+ return true if @network and @subscriber.length >= 7
32
+ false
33
+ end
29
34
 
30
35
  private
31
36
  def match_local(number)
@@ -50,5 +50,25 @@ class MsisdnTest < Test::Unit::TestCase
50
50
  assert_equal '7', msisdn.country_code
51
51
  assert_equal '79261234567', msisdn.international
52
52
  end
53
+
54
+ def test_valid_national_number
55
+ msisdn = Msisdn.new '0825559629'
56
+ assert msisdn.valid?
57
+ end
58
+
59
+ def test_invalid_national_number
60
+ msisdn = Msisdn.new '082555'
61
+ assert false == msisdn.valid?
62
+ end
63
+
64
+ def test_valid_international_number
65
+ msisdn = Msisdn.new('27825559629')
66
+ assert msisdn.valid?
67
+ end
68
+
69
+ def test_invalid_international_number
70
+ msisdn = Msisdn.new('278259629')
71
+ assert false == msisdn.valid?
72
+ end
53
73
 
54
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msisdn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armand du Plessis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-09 00:00:00 +02:00
12
+ date: 2009-11-16 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency