Class: Geocoder::IpAddress

Inherits:
String
  • Object
show all
Defined in:
lib/geocoder/ip_address.rb

Instance Method Summary collapse

Instance Method Details

#loopback?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/geocoder/ip_address.rb', line 5

def loopback?
  valid? and (self == "0.0.0.0" or self.match(/\A127\./) or self == "::1")
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/geocoder/ip_address.rb', line 9

def valid?
  !!((self =~ Resolv::IPv4::Regex) || (self =~ Resolv::IPv6::Regex))
end