Sha256: 0e126723b42f3fd1f67539f29d55d5f960969bd4d2766671e74dac1df2da9162

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 Bytes

Contents

module GovKit
  module CA
    module PostalCode
      module Strategy
        # @deprecated Due to redistribution.
        class CBCCa < Base
          base_uri 'www.cbc.ca'
          http_method :get
          path '/news/politics/canadavotes2011/myelection/postalcodes/index.php?pc=<%= @postal_code %>'

        private

          def electoral_districts!
            JSON.load(response.parsed_response).map{|x| self.class.rid_to_edid[x['rid'].to_i]}
          end

          def valid?
            response.code != 404
          end

          # cbc.ca uses an internal riding ID, which must be matched to a
          # canonical electoral district ID.
          # @return [Hash] a map of cbc.ca riding ID to electoral district ID
          def self.rid_to_edid
            @@yml ||= YAML.load_file(File.expand_path('../../../../rid_to_edid.yml', __FILE__))
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govkit-ca-0.0.14 lib/gov_kit-ca/postal_code/strategy/cbc_ca.rb
govkit-ca-0.0.13 lib/gov_kit-ca/postal_code/strategy/cbc_ca.rb