summaryrefslogtreecommitdiff
path: root/lib/ipaddr.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 22:00:31 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 22:00:31 +0000
commit91edcb053b3dd0a86ad7cec0a652d084d6e7dd46 (patch)
tree3ebfb81d7fdc03904604b2c7148180d7c6b02cec /lib/ipaddr.rb
parent4d2d744487d6f2ca97d034c7b7d5c2a4836fc5db (diff)
Merge RDoc changes from HEAD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/ipaddr.rb')
-rw-r--r--lib/ipaddr.rb45
1 files changed, 22 insertions, 23 deletions
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index ea26b374ec..17e47f016f 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -7,29 +7,9 @@
# You can redistribute and/or modify it under the same terms as Ruby.
#
# $Id$
-#--
+#
# TODO:
# - scope_id support
-#++
-#
-#== 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>
-
require 'socket'
unless Socket.const_defined? "AF_INET6"
@@ -75,8 +55,27 @@ unless Socket.const_defined? "AF_INET6"
end
end
-# IPAddr provides a set of methods to manipulate an IP address. Both
-# IPv4 and IPv6 are supported.
+# IPAddr provides a set of methods to manipulate an IP address. Both IPv4 and
+# IPv6 are supported.
+#
+# == 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>
+
class IPAddr
IN4MASK = 0xffffffff