Sha256: 8384ebad51009d5b4c2589f82a18cc2a7fe8ee3a1fa9f88b7c83fdd247e5d7f5

Contents?: true

Size: 661 Bytes

Versions: 2

Compression:

Stored size: 661 Bytes

Contents

module GovKit
  module CA
    module PostalCode
      module Strategy
        class ConservativeCa < Base
          base_uri 'www.conservative.ca'
          http_method :post
          path '/?page_id=35'
          post_data 'findmymp=35&pc=<%= @postal_code %>'

        private

          def electoral_districts!
            images.map{|a| a[:src][/\d+\.jpg\z/]}
          end

          def valid?
            !images.empty?
          end

          def images
            @document ||= Nokogiri::HTML(response.parsed_response, nil, 'utf-8').css('#type img')
          end
        end

        StrategySet.register ConservativeCa
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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