Sha256: a49567ee876da8ee56acb16413996be542f1231fe5d10417546019800e2ea6cc

Contents?: true

Size: 612 Bytes

Versions: 23

Compression:

Stored size: 612 Bytes

Contents

class Gman < NaughtyOrNice

  LOCALITY_REGEX = %r{
    (
      (state|dst|cog)
    |
      (ci|town|vil|co)\.[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 =~ LOCALITY_REGEX)
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
gman-4.1.2 lib/gman/locality.rb
gman-4.1.1 lib/gman/locality.rb
gman-4.1.0 lib/gman/locality.rb