Skip to content

Instantly share code, notes, and snippets.

@somic
Created April 14, 2009 16:18
Show Gist options
  • Save somic/95261 to your computer and use it in GitHub Desktop.
Save somic/95261 to your computer and use it in GitHub Desktop.
require 'ip'
IP::Address::IPv4.class_eval do
# returns next IP address
def next(step=1)
IP::Address::Util.unpack(self.pack + step)
end
# returns previous IP address
def prev(step=1)
IP::Address::Util.unpack(self.pack - step)
end
def to_s
ip_address
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment