Last active
February 18, 2019 15:57
-
-
Save DevoKun/d80334f284f36eba7412 to your computer and use it in GitHub Desktop.
Extend IPAddr with a method to return the value of the network range subnet mask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ipaddr' | |
class IPAddrWithMask < IPAddr | |
def mask() | |
## use _to_string private method from IPAddr class | |
_to_string(@mask_addr) | |
end ### def | |
end ### class | |
net = IPAddrWithMask.new("172.23.0.0/24") | |
puts net.mask | |
### 255.255.255.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment