subnet_calc 0.2.1 → 0.2.2

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: 7f08208310333a341c9f31757534e9e40986c827
4
- data.tar.gz: c7a36481efddf08a866a1ed2697f49f0044dbfd4
3
+ metadata.gz: bfe95c8c2371bb03c0efbd706989a2f222e9b5c0
4
+ data.tar.gz: 3ca24defd9741771d4d4f5cae620803e73fcecfe
5
5
  SHA512:
6
- metadata.gz: 71f6d30b105979461de671031e9ded95c93f98db2808571d3f63462908a3c7194502a75d73c5e1769b9ad20dfe08c667401665df464176158573991314194159
7
- data.tar.gz: a0bce9a42f943f9e654a25abb4aaad74c1bafc5955dfed872218f477aeea9508eb71e6bd5100ce105376e317035efc2de149439626177212f5956a86ec95cbeb
6
+ metadata.gz: ef8dbcec7e56ad18c6cf949aa0d2c77465f772b3d1e3072bc86b6f46cb0fa25bfe40a9f0102e29ea795a1462a57ab7b1a283257a2c8407a406b5d56dcae163ea
7
+ data.tar.gz: 57062c36c999592ee8bc9fe2b7e58303ebafaa3db4d77146791351e97c5138c87abca5bbe0916ed5470e8868a8d8273127dd5477f023ce27445b42b91e88a2c9
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/subnet_calc.rb CHANGED
@@ -90,7 +90,7 @@ class SubnetCalc
90
90
  end
91
91
 
92
92
  # determine what class of network we are using
93
- class_type = (hosts and hosts <= 254 or prefix >= 24) ? 'c' : 'b'
93
+ class_type = ((hosts and hosts <= 254) or (prefix and prefix >= 24)) ? 'c' : 'b'
94
94
 
95
95
  # Identify the network bits and the host bits
96
96
 
@@ -114,7 +114,8 @@ class SubnetCalc
114
114
 
115
115
  bit = octets[octet_n].bits[col]
116
116
 
117
- magic_number, prefix = bit.hosts_per_subnet, bit.prefix
117
+ magic_number, hosts_per_subnet, prefix = bit.decimal,
118
+ bit.hosts_per_subnet, bit.prefix
118
119
 
119
120
  no_of_subnets = (2 ** 8.0) / bit.hosts_per_subnet
120
121
 
@@ -129,7 +130,7 @@ class SubnetCalc
129
130
 
130
131
  subnets = case class_type
131
132
  when 'c'
132
- class_subnets(segments, magic_number)
133
+ class_subnets(segments, hosts_per_subnet)
133
134
  when 'b'
134
135
  class_b_subnets(256 / segments, bit.decimal)
135
136
  end
@@ -142,7 +143,7 @@ class SubnetCalc
142
143
  result = {
143
144
  class_type: class_type.upcase,
144
145
  magic_number: magic_number,
145
- hosts: magic_number - 2,
146
+ hosts: hosts_per_subnet - 2,
146
147
  subnet_mask: subnet_mask,
147
148
  subnet_bitmask: subnet_mask.split('.').map {|x| x.to_i.to_s(2)},
148
149
  prefix: prefix,
@@ -199,7 +200,7 @@ Summary
199
200
 
200
201
  * Network class: #{@h[:class_type]}
201
202
  * magic number: #{@h[:magic_number]}
202
- * hosts per subnet (magic number - 2 ): #{@h[:hosts]}
203
+ * hosts per subnet: #{@h[:hosts]}
203
204
  * subnet mask: #{@h[:subnet_mask]}
204
205
  * subnet bitmask: #{@h[:subnet_bitmask].join('.')}
205
206
  * prefix bit-length: #{@h[:prefix]}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subnet_calc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file