diff options
Diffstat (limited to 'lib/ipaddr.rb')
-rw-r--r-- | lib/ipaddr.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb index a45055496c..525466bbd9 100644 --- a/lib/ipaddr.rb +++ b/lib/ipaddr.rb @@ -151,6 +151,16 @@ class IPAddr return self.clone.set(addr_mask(~@addr)) end + # Returns a new ipaddr greater than the original address by offset + def +(offset) + self.clone.set(@addr + offset, @family) + end + + # Returns a new ipaddr less than the original address by offset + def -(offset) + self.clone.set(@addr - offset, @family) + end + # Returns true if two ipaddrs are equal. def ==(other) other = coerce_other(other) |