summaryrefslogtreecommitdiff
path: root/lib/ipaddr.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipaddr.rb')
-rw-r--r--lib/ipaddr.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index c1073ecd2b..dbb213c90a 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -227,6 +227,12 @@ class IPAddr
return str
end
+ # Returns a string containing the IP address representation in
+ # cidr notation
+ def cidr
+ format("%s/%s", to_s, prefix)
+ end
+
# Returns a network byte ordered string form of the IP address.
def hton
case @family