Sha256: a99dbd23f05093a068d0b28305b45836860650dc2f0aa81c5dd2c1f0c60c2bc2

Contents?: true

Size: 758 Bytes

Versions: 3

Compression:

Stored size: 758 Bytes

Contents

module GovKit
  module CA
    module PostalCode
      module Strategy
        # elections.ca is a reliable source, but it does not return electoral
        # districts for postal codes that contain multiple electoral districts.
        # @see https://github.com/danielharan/postal_code_to_edid_webservice
        class ElectionsCa < Base
          base_uri 'elections.ca'
          http_method :head
          path '/scripts/pss/FindED.aspx?PC=<%= @postal_code %>'

        private

          def electoral_districts!
            [ response.headers['location'][/\bED=(\d{5})&/, 1] ]
          end

          def valid?
            !!response.headers['location']
          end
        end

        StrategySet.register ElectionsCa
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
govkit-ca-0.0.6 lib/gov_kit-ca/postal_code/strategy/elections_ca.rb
govkit-ca-0.0.5 lib/gov_kit-ca/postal_code/strategy/elections_ca.rb
govkit-ca-0.0.4 lib/gov_kit-ca/postal_code/strategy/elections_ca.rb