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)


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

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

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  !!self.match(/\A(::ffff:)?(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/)
end