Method: IP::Address::Util.string_to_ip
- Defined in:
- lib/ip/util.rb
.string_to_ip(s) ⇒ Object
This takes a string which supposedly contains an IP address, and tries to figure out if it is a IPv6 or IPv4 address. Returns a constructed object of the proper type.
137 138 139 140 |
# File 'lib/ip/util.rb', line 137 def string_to_ip(s) return IP::Address::IPv6.new(s) if s.match(/:/) return IP::Address::IPv4.new(s) end |