class IPAddr::V4
An IPv4 address, 32 bits
Constants
- NETWORK_CLASSES
- REGEX
Public Instance Methods
classful()
click to toggle source
If the address falls in one of the address classes defined in rfc791, return a new IPAddr
with the appropriate prefix length, otherwise return nil.
-
Class A: networks of 16,777,216 addresses each, from 0.0.0.0/8 to 127.0.0.0/8
-
Class B: networks of 65,537 addresses each, from 128.0.0.0/16 to 191.255.0.0/16
-
Class C: networks of 256 addresses each, from 192.0.0.0/24 to 223.255.255.0/24
@return [IPAddr::V4, nil]
# File lib/better_ipaddr/classes.rb, line 369 def classful prefix_length = classful_prefix_length || return mask(prefix_length) end
classful_prefix_length()
click to toggle source
If the address falls in one of the address classes defined in rfc791, return the corresponding prefix length, otherwise return nil.
@return [Integer, nil]
# File lib/better_ipaddr/classes.rb, line 378 def classful_prefix_length key = NETWORK_CLASSES.keys.find do |block| block.to_range(&:to_i).cover?(to_i) end NETWORK_CLASSES[key] end