lib/ipaddress_2/ipv4.rb
#
# Returns a new IPv4 object which is the result 
# of advancing this IP address by a given value.
# In other words, this arithmetically adds IP addresses.
#
# Will raise an error if the resulting address is in a different subnet,
# except validating is set to false.
#
# Example:
#
#   ip = IPAddress::IPv4.new("172.16.10.1/24")
#   ip.add(5).to_string
#     #=> "172.16.10.6/24"
Returns a new IPv4 object which is the result
of advancing this IP address by a given value.
In other words, this arithmetically adds IP addresses.

Will raise an error if the resulting address is in a different subnet,
except validating is set to false.




Returns a new IPv4 object which is the result of advancing this IP address by a given value . In other words this arithmetically adds IP addresses . Will raise an error if the resulting address is in a different subnet except validating is set to false .
def add(oth, validating=true)
      oth = oth.to_i if oth.kind_of? IPAddress::IPv4 
      new_obj = self.class.parse_u32(self.to_i + oth, prefix)
      if validating and self.network_u32 != new_obj.network_u32
        raise RuntimeError, "Subnet (/#{@prefix}) is not large enough."
      end
      new_obj
    end
def add ( oth , validating = true ) oth = oth . to_i if oth . kind_of? IPAddress :: IPv4 new_obj = self . class . parse_u32 ( self . to_i + oth , prefix ) if validating and self . network_u32 != new_obj . network_u32 raise RuntimeError , "Subnet (/#{@prefix}) is not large enough." end new_obj end
Returns a new IPv4 object which is the result
of advancing this IP address by a given value.
Returns a new IPv4 object which is the result of advancing this IP address by a given value .
# oth shall be integer
oth
<not_specific>
validating
<not_specific>