Ruby's standard library includes regular expressions to validate an IP address. The Resolv standard library includes a regex for IPv4 and IPv6 addresses.
I benchmarked some tests run in JRuby that compare the Hamsterdam library using Hamster's immutable Hashes vs Clojure's PeristentHashMap, plus some gotchas.