class IPAddr
reopen class to add needed methods for IP/subnetwork stuff
Public Instance Methods
broadcast_address()
click to toggle source
compute broadcast address
# File lib/wire/resource/ipaddr_ext.rb, line 16 def broadcast_address _to_string(@addr | (2**32 - 1) - (@mask_addr)) end
in_range_of?(network)
click to toggle source
checks if self is within network range of given network
(IPAddr
object) i.e. 10.10.2.0/24 is part of 10.10.0.0/16 params: network
i.e. 10.10.0.0/16, if self == 10.10.2.0/24 returns
- bool
# File lib/wire/resource/ipaddr_ext.rb, line 27 def in_range_of?(network) return false unless network.include?(self) return false unless network.include?(IPAddr.new(broadcast_address)) true end
netmask()
click to toggle source
return netmask as a string
# File lib/wire/resource/ipaddr_ext.rb, line 35 def netmask _to_string(@mask_addr) end