Skip to content

Instantly share code, notes, and snippets.

@ton31337
Last active January 29, 2016 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ton31337/0544072f0106d6868951 to your computer and use it in GitHub Desktop.
Save ton31337/0544072f0106d6868951 to your computer and use it in GitHub Desktop.
def ipv6?(ip)
ipv6_global = IPAddr.new('2000::/3')
ipv6_global.include?(ip)
end
def to_ipv6(ip)
"[#{ip}]" if ipv6?(ip)
end
ips = ['192.168.1.1', '2001::dead::5', '10.0.0.1', '2001::beef']
x = ips.to_ipv6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment