Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed some IPv6 documentation (closes #8)

  • Loading branch information...
commit bda1e2bb645cf6dcba6fc65f9c9ef12d8003505e 1 parent c2945c5
@bluemonk authored
Showing with 30 additions and 30 deletions.
  1. +1 −1  CHANGELOG.rdoc
  2. +8 −8 README.rdoc
  3. +21 −21 lib/ipaddress/ipv6.rb
View
2  CHANGELOG.rdoc
@@ -1,6 +1,6 @@
== ipaddress 0.8.0
-CHANGED:: Removed extension methods and extension directory to easy integration with the stdlib
+CHANGED:: Removed extension methods and extension directory to facilitate integration with the stdlib
CHANGED:: Reworked IPv4#<=>, now intuitively sorts objects based on the prefix
CHANGED:: IPv4#supernet now returns "0.0.0.0/0" if supernetting with a prefix less than 1
NEW:: IPv6#network
View
16 README.rdoc
@@ -572,7 +572,7 @@ eight groups of four hexadecimal digits, each group representing 16
bits or two octet. For example, the following is a valid IPv6
address:
- 1080:0000:0000:0000:0008:0800:200c:417a
+ 2001:0db8:0000:0000:0008:0800:200c:417a
Letters in an IPv6 address are usually written downcase, as per
RFC. You can create a new IPv6 object using uppercase letters, but
@@ -592,7 +592,7 @@ simplifications and compressions that you can use to shorten them.
Using compression, the IPv6 address written above can be shorten into
the following, equivalent, address
- 1080::8:800:200c:417a
+ 2001:db8::8:800:200c:417a
This short version is often used in human representation.
@@ -601,7 +601,7 @@ This short version is often used in human representation.
As we used to do with IPv4 addresses, an IPv6 address can be written
using the prefix notation to specify the subnet mask:
- 1080::8:800:200c:417a/64
+ 2001:db8::8:800:200c:417a/64
The /64 part means that the first 64 bits of the address are
representing the network portion, and the last 64 bits are the host
@@ -612,11 +612,11 @@ portion.
All the IPv6 representations we've just seen are perfectly fine when
you want to create a new IPv6 address:
- ip6 = IPAddress "1080:0000:0000:0000:0008:0800:200C:417A"
+ ip6 = IPAddress "2001:0db8:0000:0000:0008:0800:200C:417A"
- ip6 = IPAddress "1080:0:0:0:8:800:200C:417A"
+ ip6 = IPAddress "2001:db8:0:0:8:800:200C:417A"
- ip6 = IPAddress "1080::8:800:200C:417A"
+ ip6 = IPAddress "2001:db8:8:800:200C:417A"
All three are giving out the same IPv6 object. The default subnet mask
for an IPv6 is 128, as IPv6 addresses don't have classes like IPv4
@@ -744,13 +744,13 @@ like in the following example:
A new IPv6 address can also be created from an unsigned 128 bits
integer:
- u128 = 21932261930451111902915077091070067066
+ u128 = 42540766411282592856906245548098208122
ip6 = IPAddress::IPv6::parse_u128 u128
ip6.prefix = 64
ip6.to_string
- #=> "1080::8:800:200c:417a/64"
+ #=>"2001:db8::8:800:200c:417a/64"
Finally, a new IPv6 address can be created from an hex string:
View
42 lib/ipaddress/ipv6.rb
@@ -22,7 +22,7 @@ module IPAddress;
# bits or two octect. For example, the following is a valid IPv6
# address:
#
- # 1080:0000:0000:0000:0008:0800:200c:417a
+ # 2001:0db8:0000:0000:0008:0800:200c:417a
#
# Letters in an IPv6 address are usually written downcase, as per
# RFC. You can create a new IPv6 object using uppercase letters, but
@@ -42,7 +42,7 @@ module IPAddress;
# Using compression, the IPv6 address written above can be shorten into
# the following, equivalent, address
#
- # 1080::8:800:200c:417a
+ # 2001:db8::8:800:200c:417a
#
# This short version is often used in human representation.
#
@@ -51,7 +51,7 @@ module IPAddress;
# As we used to do with IPv4 addresses, an IPv6 address can be written
# using the prefix notation to specify the subnet mask:
#
- # 1080::8:800:200c:417a/64
+ # 2001:db8::8:800:200c:417a/64
#
# The /64 part means that the first 64 bits of the address are
# representing the network portion, and the last 64 bits are the host
@@ -75,9 +75,9 @@ class IPv6
#
# An IPv6 address can be expressed in any of the following forms:
#
- # * "1080:0000:0000:0000:0008:0800:200C:417A": IPv6 address with no compression
- # * "1080:0:0:0:8:800:200C:417A": IPv6 address with leading zeros compression
- # * "1080::8:800:200C:417A": IPv6 address with full compression
+ # * "2001:0db8:0000:0000:0008:0800:200C:417A": IPv6 address with no compression
+ # * "2001:db8:0:0:8:800:200C:417A": IPv6 address with leading zeros compression
+ # * "2001:db8::8:800:200C:417A": IPv6 address with full compression
#
# In all these 3 cases, a new IPv6 address object will be created, using the default
# subnet mask /128
@@ -580,18 +580,18 @@ def self.parse_data(str)
# Creates a new IPv6 object from an
# unsigned 128 bits integer.
#
- # ip6 = IPAddress::IPv6::parse_u128(21932261930451111902915077091070067066)
+ # ip6 = IPAddress::IPv6::parse_u128(42540766411282592856906245548098208122)
# ip6.prefix = 64
#
- # ip6.to_s
- # #=> "1080::8:800:200c:417a/64"
+ # ip6.to_string
+ # #=> "2001:db8::8:800:200c:417a/64"
#
# The +prefix+ parameter is optional:
#
- # ip6 = IPAddress::IPv6::parse_u128(21932261930451111902915077091070067066, 64)
+ # ip6 = IPAddress::IPv6::parse_u128(42540766411282592856906245548098208122, 64)
#
- # ip6.to_s
- # #=> "1080::8:800:200c:417a/64"
+ # ip6.to_string
+ # #=> "2001:db8::8:800:200c:417a/64"
#
def self.parse_u128(u128, prefix=128)
str = IN6FORMAT % (0..7).map{|i| (u128>>(112-16*i))&0xffff}
@@ -605,15 +605,15 @@ def self.parse_u128(u128, prefix=128)
# ip6 = IPAddress::IPv6::parse_hex("20010db80000000000080800200c417a")
# ip6.prefix = 64
#
- # ip6.to_s
+ # ip6.to_string
# #=> "2001:db8::8:800:200c:417a/64"
#
# The +prefix+ parameter is optional:
#
# ip6 = IPAddress::IPv6::parse_hex("20010db80000000000080800200c417a", 64)
#
- # ip6.to_s
- # #=> "1080::8:800:200c:417a/64"
+ # ip6.to_string
+ # #=> "2001:db8::8:800:200c:417a/64"
#
def self.parse_hex(hex, prefix=128)
self.parse_u128(hex.hex, prefix)
@@ -715,14 +715,14 @@ def initialize
#
# ip = IPAddress::IPv6::Loopback.new
#
- # ip.to_s
+ # ip.to_string
# #=> "::1/128"
#
# or by using the wrapper:
#
# ip = IPAddress "::1"
#
- # ip.to_s
+ # ip.to_string
# #=> "::1/128"
#
# Checking if an address is loopback is easy with the IPv6#loopback?
@@ -739,7 +739,7 @@ class IPAddress::IPv6::Loopback < IPAddress::IPv6
#
# ip = IPAddress::IPv6::Loopback.new
#
- # ip.to_s
+ # ip.to_string
# #=> "::1/128"
#
def initialize
@@ -778,7 +778,7 @@ def initialize
# ip6.mapped?
# #=> true
#
- # ip6.to_s
+ # ip6.to_string
# #=> "::FFFF:172.16.10.1/128"
#
# Now with the +ipv4+ attribute, we can easily access the IPv4 portion
@@ -805,7 +805,7 @@ def initialize
# That is, two colons and the IPv4 address. However, as by RFC, the ffff
# group will be automatically added at the beginning
#
- # ip6.to_s
+ # ip6.to_string
# => "::ffff:172.16.10.1/128"
#
# making it a mapped IPv6 compatible address.
@@ -828,7 +828,7 @@ class IPAddress::IPv6::Mapped < IPAddress::IPv6
#
# ip6 = IPAddress::IPv6::Mapped.new "::0d01:4403"
#
- # ip6.to_s
+ # ip6.to_string
# #=> "::ffff:13.1.68.3"
#
def initialize(str)
Please sign in to comment.
Something went wrong with that request. Please try again.