Method: Pio::IPv4Address#prefixlen
- Defined in:
- lib/pio/ipv4_address.rb
#prefixlen ⇒ Number
Returns prefix length of IPv4 address.
50 51 52 53 54 55 56 57 |
# File 'lib/pio/ipv4_address.rb', line 50 def prefixlen netmask = to_range.first.to_i ^ to_range.last.to_i if netmask > 0 32 - format('%b', netmask).length else 32 end end |