method
in6_addr
in6_addr(left)
private
Hide source
# File lib/ipaddr.rb, line 520 def in6_addr(left) case left when /^::ffff:(\d+\.\d+\.\d+\.\d+)$/ return in_addr($1) + 0xffff00000000 when /^::(\d+\.\d+\.\d+\.\d+)$/ return in_addr($1) when /[^0-9a-f:]/ 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 return (l + Array.new(rest, '0') + r).inject(0) { |i, s| i << 16 | s.hex } end