Sha256: 701b8bc7075dc2d004184c75017ce277db0c67b8b4a1bd227dd1aadec1198a26

Contents?: true

Size: 648 Bytes

Versions: 10

Compression:

Stored size: 648 Bytes

Contents

class Gman

  LOCALITY_REGEX = %r{
    (
      (state|dst|cog)
    |
      (ci|co|borough|boro|city|county|parish|town|twp|vi|vil|village)\.[a-z-]+
    )
    \.(ak|al|ar|az|ca|co|ct|dc|de|fl|ga|hi|ia|id|il|in|ks|ky|la|ma|md|me|mi|mn|mo|ms|mt|nc|nd|ne|nh|nj|nm|nv|ny|oh|ok|or|pa|ri|sc|sd|tn|tx|um|ut|va|vt|wa|wi|wv|wy)
    \.us
     }x

  # Second level .us domains for states and locality
  # See http://en.wikipedia.org/wiki/.us
  #
  # Examples:
  #  * foo.state.il.us
  #  * ci.foo.il.us
  #
  # Not:
  #  * state.foo.il.us
  #  * foo.ci.il.us
  #  * k12.il.us
  #  * ci.foo.zx.us
  def locality?
    !!(domain.to_s =~ LOCALITY_REGEX)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gman-5.0.9 lib/gman/locality.rb
gman-5.0.8 lib/gman/locality.rb
gman-5.0.7 lib/gman/locality.rb
gman-5.0.6 lib/gman/locality.rb
gman-5.0.5 lib/gman/locality.rb
gman-5.0.4 lib/gman/locality.rb
gman-5.0.3 lib/gman/locality.rb
gman-5.0.2 lib/gman/locality.rb
gman-5.0.1 lib/gman/locality.rb
gman-5.0.0 lib/gman/locality.rb