Sha256: 561933f3f0a80986bb5ee3131ccfe63d2de9a3081d0bf22ca9902527d63b3faa

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 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('../../../../rid_to_edid.yml', __FILE__))
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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