summaryrefslogtreecommitdiff
path: root/README.rdoc
diff options
context:
space:
mode:
authorMarco Ceresa <ceresa@gmail.com>2010-05-20 15:49:00 +0100
committerMarco Ceresa <ceresa@gmail.com>2010-05-20 15:49:00 +0100
commit636f76a410b99d78867bbc8521e3dc5ae6263c8c (patch)
treeaefed6234b03e0abc02056c59d76bec9938bd0b9 /README.rdoc
parentfbe865911ad4e4c15c5baac719db0df20ef45b58 (diff)
downloadipaddress-636f76a410b99d78867bbc8521e3dc5ae6263c8c.tar.gz
Completed most documentation on README.rdoc and ipv6.rb
Diffstat (limited to 'README.rdoc')
-rw-r--r--README.rdoc31
1 files changed, 28 insertions, 3 deletions
diff --git a/README.rdoc b/README.rdoc
index 4c3da5a..c8d5143 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -643,12 +643,37 @@ actually created internally).
You can create a new IPv6 address from different formats than just a
string representing the colon-hex groups.
+For instance, if you have a data stream, you can use IPv6::parse_data,
+like in the following example:
+ data = " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
-The subnet mask can be changed on a later stage by using the
-appropriate setter:
+ ip6 = IPAddress::IPv4::parse_data data
+ ip6.prefix = 64
-
+ ip6.to_s
+ #=> "2001:db8::8:800:200c:417a/64"
+
+A new IPv6 address can also be created from an unsigned 128 bits
+integer:
+
+ u128 = 21932261930451111902915077091070067066
+
+ ip6 = IPAddress::IPv6::parse_u128 u128
+ ip6.prefix = 64
+
+ ip6.to_s
+ #=> "1080::8:800:200c:417a/64"
+
+Finally, a new IPv6 address can be created from an hex string:
+
+ hex = "20010db80000000000080800200c417a"
+
+ ip6 = IPAddress::IPv6::parse_hex hex
+ ip6.prefix = 64
+
+ ip6.to_s
+ #=> "2001:db8::8:800:200c:417a/64"
== Special IPv6 addresses