pio 0.2.3 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 816bf0b85b7f5e9caf3f8ca48d3999ed7d527d0a
4
- data.tar.gz: f10c68b32919477b6ec261ef9fecfd3301cfff15
3
+ metadata.gz: 8b1a7685cf52cf2c1130a376ecbb0deb4d3bab6f
4
+ data.tar.gz: dedeebabbd435531e5937344abd6c774e781b45b
5
5
  SHA512:
6
- metadata.gz: 39eaa53aed3cdb6faaadd90d75b30f0b69b274a5d5809e4acb65291e1ffd79f7c608f77ffc1b1b2ec27b05cf54e2802bf8b31c5431de38cbff8ab512214e386b
7
- data.tar.gz: c5565b02e2cc265897dd79c5a91d665c406070cd68a1a4361dbb3982d1684147e3361ee9dfbfd64bec49b577c1852bf51518c9403f3753e1ba4aa0dfc7e57ec1
6
+ metadata.gz: e3ec7121d3566f35e7c1b282019fbd38325c4c9910739a29e3407f2c5d58916f8d07306b3a8cf3fe65315c3c68c6a3aebc702a8e9866bf6a589434fdb338a3e6
7
+ data.tar.gz: 3844655945ad07e364deab3923dfeb702b96db4c2398e7a9511fbbf4592c381e10143dba62ee4d2cc7d098cb16e0c8ff260c02dbd433409a9d966dc1db96e1f8
@@ -66,7 +66,11 @@ module Pio
66
66
  #
67
67
  def prefixlen
68
68
  netmask = to_range.first.to_i ^ to_range.last.to_i
69
- 32 - ( "%b" % netmask ).length
69
+ if netmask > 0
70
+ 32 - ( "%b" % netmask ).length
71
+ else
72
+ 32
73
+ end
70
74
  end
71
75
 
72
76
 
data/lib/pio/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Base module.
2
2
  module Pio
3
3
  # gem version.
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
6
6
 
7
7
 
@@ -11,7 +11,8 @@ module Pio
11
11
  let( :ip_address ) { "10.1.1.1" }
12
12
 
13
13
  its( :to_s ) { should eq "10.1.1.1" }
14
- its( :to_i ) { should eq ( ( 10 * 256 + 1 ) * 256 + 1 ) * 256 + 1 }
14
+ its( :to_i ) { should eq ( ( ( 10 * 256 + 1 ) * 256 + 1 ) * 256 + 1 ) }
15
+ its( :prefixlen ) { should eq 32 }
15
16
  its( :to_ary ) { should eq [ 0x0a, 0x01, 0x01, 0x01 ] }
16
17
  its( :class_a? ) { should be_true }
17
18
  its( :class_b? ) { should be_false }
@@ -45,7 +46,7 @@ module Pio
45
46
  let( :ip_address ) { "172.20.1.1" }
46
47
 
47
48
  its( :to_s ) { should eq "172.20.1.1" }
48
- its( :to_i ) { should eq ( ( 172 * 256 + 20 ) * 256 + 1 ) * 256 + 1 }
49
+ its( :to_i ) { should eq ( ( ( 172 * 256 + 20 ) * 256 + 1 ) * 256 + 1 ) }
49
50
  its( :to_ary ) { should eq [ 0xac, 0x14, 0x01, 0x01 ] }
50
51
  its( :class_a? ) { should be_false }
51
52
  its( :class_b? ) { should be_true }
@@ -77,7 +78,7 @@ module Pio
77
78
  let( :ip_address ) { "234.1.1.1" }
78
79
 
79
80
  its( :to_s ) { should eq "234.1.1.1" }
80
- its( :to_i ) { should eq ( ( 234 * 256 + 1 ) * 256 + 1 ) * 256 + 1 }
81
+ its( :to_i ) { should eq ( ( ( 234 * 256 + 1 ) * 256 + 1 ) * 256 + 1 ) }
81
82
  its( :to_ary ) { should eq [ 0xea, 0x01, 0x01, 0x01 ] }
82
83
  its( :class_a? ) { should be_false }
83
84
  its( :class_b? ) { should be_false }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhito Takamiya