diff options
author | Gregory Graf <graf.gregory@gmail.com> | 2015-05-31 11:32:38 -0500 |
---|---|---|
committer | Gregory Graf <graf.gregory@gmail.com> | 2015-05-31 11:32:38 -0500 |
commit | c118c7174a6939cbdfd35f9aaaa39c93a30cd452 (patch) | |
tree | e7f47f83c6042f72162209e5dd9776e505528696 /lib/ipaddress | |
parent | 8fa088ba7d20ca2e13909265bc9b00c4f64c2edf (diff) | |
download | ipaddress-c118c7174a6939cbdfd35f9aaaa39c93a30cd452.tar.gz |
Raise ArgumentError if IP address is nil
Diffstat (limited to 'lib/ipaddress')
-rw-r--r-- | lib/ipaddress/ipv4.rb | 1 | ||||
-rw-r--r-- | lib/ipaddress/ipv6.rb | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb index 7d8e0d3..cbccac0 100644 --- a/lib/ipaddress/ipv4.rb +++ b/lib/ipaddress/ipv4.rb @@ -61,6 +61,7 @@ module IPAddress; # IPAddress::IPv4.new "10.0.0.1/255.0.0.0" # def initialize(str) + raise ArgumentError, "Nil IP" unless str ip, netmask = str.split("/") # Check the ip and remove white space diff --git a/lib/ipaddress/ipv6.rb b/lib/ipaddress/ipv6.rb index 88098bc..76f8715 100644 --- a/lib/ipaddress/ipv6.rb +++ b/lib/ipaddress/ipv6.rb @@ -87,6 +87,7 @@ module IPAddress; # ip6 = IPAddress "2001:db8::8:800:200c:417a/64" # def initialize(str) + raise ArgumentError, "Nil IP" unless str ip, netmask = str.split("/") if str =~ /:.+\./ |