Sha256: 4062d19984e9e2b8d5b394afc11e10c38812e68dbe361e6101de366a0d87019b

Contents?: true

Size: 709 Bytes

Versions: 1

Compression:

Stored size: 709 Bytes

Contents

module GovKit
  module CA
    module PostalCode
      module Strategy
        # liberal.ca seems unreliable. It returns three ridings for K0A1K0.
        class LiberalCa < Base
          follow_redirects true
          base_uri 'www.liberal.ca'
          http_method :get
          path '/riding/postal/<%= @postal_code %>/'

        private

          def electoral_districts!
            Nokogiri::HTML(response.parsed_response, nil, 'utf-8').css('img.RidingListImage').map{|img| img[:src][/\d{5}/]}
          end

          def valid?
            !response.parsed_response["Sorry we couldn't find your riding."]
          end
        end

        StrategySet.register LiberalCa
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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