Sha256: 6660ee3ef60dfcb08ecce6ca5d63064d1d44b162ce726b28674ed0df087dd7a2

Contents?: true

Size: 245 Bytes

Versions: 6

Compression:

Stored size: 245 Bytes

Contents

module Geocoder
  class IpAddress < String

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geocoder-1.2.5 lib/geocoder/ip_address.rb
geocoder-1.2.4 lib/geocoder/ip_address.rb
geocoder-1.2.3 lib/geocoder/ip_address.rb
geocoder-1.2.2 lib/geocoder/ip_address.rb
geocoder-1.2.1 lib/geocoder/ip_address.rb
geocoder-1.2.0 lib/geocoder/ip_address.rb