method
in6_addr
in6_addr(left)
private
Hide source
# File lib/ipaddr.rb, line 457 def in6_addr(left) case left when /^::ffff:(\d+\.\d+\.\d+\.\d+)$/i return in_addr($1) + 0xffff00000000 when /^::(\d+\.\d+\.\d+\.\d+)$/i return in_addr($1) when /[^0-9a-f:]/i raise ArgumentError, "invalid address" when /^(.*)::(.*)$/ left, right = $1, $2 else right = '' end l = left.split(':') r = right.split(':') rest = 8 - l.size - r.size if rest < 0 return nil end a = [l, Array.new(rest, '0'), r].flatten! n = 0 a.each { |i| n <<= 16 n += i.hex } return n end