diff options
author | Ben Fritsch <[email protected]> | 2020-04-03 16:48:15 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-04-18 10:27:19 +0900 |
commit | 6ac8f6a10eb011147a6cdaf4cf4154c41a7d9080 (patch) | |
tree | 5232d2c12492623905e6f1a999522beaec8ff4f9 /lib/ipaddr.rb | |
parent | 07771c7657e65e8da6cd11eacbb105bdf46d0f10 (diff) |
[ruby/ipaddr] Add IPAddr.cidr to return ip address in cidr notation
https://github.com/ruby/ipaddr/commit/f5b006741f
Diffstat (limited to 'lib/ipaddr.rb')
-rw-r--r-- | lib/ipaddr.rb | 6 |
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 |