Method: IPAddress::IPv6.parse_data

Defined in:
lib/ipaddress/ipv6.rb

.parse_data(str) ⇒ Object

Creates a new IPv6 object from binary data, like the one you get from a network stream.

For example, on a network stream the IP

"2001:db8::8:800:200c:417a"

is represented with the binary data

" \001\r\270\000\000\000\000\000\b\b\000 \fAz"

With that data you can create a new IPv6 object:

ip6 = IPAddress::IPv6::parse_data " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
ip6.prefix = 64

ip6.to_s
  #=> "2001:db8::8:800:200c:417a/64"


584
585
586
# File 'lib/ipaddress/ipv6.rb', line 584

def self.parse_data(str)
  self.new(IN6FORMAT % str.unpack("n8"))
end