better_ipaddr 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ed17817f83f96eded43b12590ef72c44d0a9401
4
- data.tar.gz: d34e87185a8782e54770b2cc9742b0c9ed181f4d
3
+ metadata.gz: 44911d183145a57efbc10650b9f7da538ca39613
4
+ data.tar.gz: 3291ad4bf6a24bbcd557d57b33af26ea4d8695c0
5
5
  SHA512:
6
- metadata.gz: 8c0f15d01aa3400be71df5ef322b2080af790e80674bd306a5af943371462783368f4afc2306d30215162f5a9fb79206a840e63a6c0d6f2004d236c4aa0845c1
7
- data.tar.gz: 854ec695469d3ee8a46abfbf27d7af4e212456b8ab90af82df7d7b9fe3af135513a88ba14ff1061f54d23935bc3f7ccf26a5b1a0514e0db72c99975df4510560
6
+ metadata.gz: 851ccffe6d759df96863562ff26e12cb3446450d9b57e0a6887a9eeabf0b80df9ffe53585fd1486f1f2043016cce4c8e7172361432e2011a1f4641696f64ba0d
7
+ data.tar.gz: 82966ccbd03491190b9bcbf73c2bd73f9ba4d52aa0c8fa739e2a9d2287f6c5cfd9e7cf74041832146d95fa9f8950de18980d196d58686c473db7c67f4bfb2a3a
@@ -12,8 +12,15 @@ class IPAddr
12
12
  end
13
13
 
14
14
  def self.[](address, mask = nil, family: self::FAMILY)
15
- if mask
16
- new(address, family).mask(new(mask, family).to_s)
15
+ case mask
16
+ when Integer
17
+ if 0 <= mask && mask <= FAMILY_TO_BIT_LENGTH[family]
18
+ new(address, family).mask(mask)
19
+ else
20
+ new(address, family).mask(new(mask, family).to_s)
21
+ end
22
+ when String, IPAddr
23
+ new(address, family).mask(mask.to_s)
17
24
  else
18
25
  new(address, family)
19
26
  end
@@ -1,3 +1,3 @@
1
1
  module BetterIpaddr
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_ipaddr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Miller
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  requirements: []
97
97
  rubyforge_project:
98
- rubygems_version: 2.5.1
98
+ rubygems_version: 2.4.5.1
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: IPAddr enhancements for network management.