Sha256: d9309b04f97132a4b9368a51b10f9517acb2cf0d932002a82dfc236ca34a5817
Contents?: true
Size: 753 Bytes
Versions: 1
Compression:
Stored size: 753 Bytes
Contents
module Vagrant module Util module NetworkIP # Returns the network address of the given IP and subnet. # # @return [String] def network_address(ip, subnet) ip = ip_parts(ip) netmask = ip_parts(subnet) # Bitwise-AND each octet to get the network address # in octets and join each part with a period to get # the resulting network address. ip.map { |part| part & netmask.shift }.join(".") end protected # Splits an IP into the four octets and returns each as an # integer in an array. # # @return [Array<Integer>] def ip_parts(ip) ip.split(".").map { |i| i.to_i } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-cloudstack-1.2.0 | vendor/bundle/bundler/gems/vagrant-c84e05fd063f/lib/vagrant/util/network_ip.rb |