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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/subnet_calc.rb +6 -5
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfe95c8c2371bb03c0efbd706989a2f222e9b5c0
|
4
|
+
data.tar.gz: 3ca24defd9741771d4d4f5cae620803e73fcecfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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,
|
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:
|
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
|
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
metadata.gz.sig
CHANGED
Binary file
|