Sha256: 2ec6fb7e5db34f66202ca5ed45b1e65218cb5fd89f504691aa468765089e7fdd

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

module GovKit
  module CA
    module PostalCode
      module Strategy
        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('../../../../data/rid_to_edid.yml', __FILE__))
          end
        end

        StrategySet.register CBCCa
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govkit-ca-0.0.10 lib/gov_kit-ca/postal_code/strategy/cbc_ca.rb
govkit-ca-0.0.9 lib/gov_kit-ca/postal_code/strategy/cbc_ca.rb
govkit-ca-0.0.8 lib/gov_kit-ca/postal_code/strategy/cbc_ca.rb
govkit-ca-0.0.7 lib/gov_kit-ca/postal_code/strategy/cbc_ca.rb