ipaddr.rb
| Path: | ipaddr.rb |
| Last Update: | Wed Jan 19 09:14:42 GMT 2005 |
ipaddr.rb - A class to manipulate an IP address Copyright (c) 2002 Hajimu UMEMOTO <ume@mahoroba.org>. All rights reserved. You can redistribute and/or modify it under the same terms as Ruby. $Id: ipaddr.rb,v 1.5.2.2 2005/01/19 09:14:42 usa Exp $
Example
require 'ipaddr' ipaddr1 = IPAddr.new "3ffe:505:2::1" p ipaddr1 #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff> p ipaddr1.to_s #=> "3ffe:505:2::1" ipaddr2 = ipaddr1.mask(48) #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000> p ipaddr2.to_s #=> "3ffe:505:2::" ipaddr3 = IPAddr.new "192.168.2.0/24" p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
Required files
socket