Class: Geocoder::IpAddress
- Inherits:
-
String
- Object
- String
- Geocoder::IpAddress
- Defined in:
- lib/geocoder/ip_address.rb
Instance Method Summary collapse
Instance Method Details
#loopback? ⇒ Boolean
4 5 6 |
# File 'lib/geocoder/ip_address.rb', line 4 def loopback? valid? and (self == "0.0.0.0" or self.match(/\A127\./) or self == "::1") end |
#valid? ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/geocoder/ip_address.rb', line 8 def valid? ipregex = %r{ \A( # String Starts ((::ffff:)?((\d{1,3})\.){3}\d{1,3}) # Check for IPv4 | # .... Or (\S+?(:\S+?){6}\S+) # Check for IPv6 | # .... Or (::1) # IPv6 loopback )\z }x !!self.match(ipregex) end |