Sha256: 7f43de9069b9a4f3726893be22ba4c840ef83a6d4029c3902d32f55b7ea87836

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

module Crags
  class Country
    include Fetcher
    attr_reader :code

    def initialize(code)
      @code = code
    end

    def url
      "#{Config.country_url}/#{code}"
    end

    def doc
      fetch_doc(url)
    end

    def request
      fetch_request(url)
    end

    def links
      doc.search("#list a")
    end

    def locations
      if links.empty?
        str = request.last_effective_url
        [Location.new(str.strip_http)]
      else
        links.collect do |link|
          Location.new(link["href"].strip_http)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crags-2.0.0 lib/crags/country.rb