Method: IPAddress::IPv6.groups
- Defined in:
- lib/ipaddress/ipv6.rb
.groups(str) ⇒ Object
Extract 16 bits groups from a string
555 556 557 558 559 560 561 562 |
# File 'lib/ipaddress/ipv6.rb', line 555 def self.groups(str) l, r = if str =~ /^(.*)::(.*)$/ [$1,$2].map {|i| i.split ":"} else [str.split(":"),[]] end (l + Array.new(8-l.size-r.size, '0') + r).map {|i| i.hex} end |