Sha256: 87fa70a956422a46b801551f3710bfdce130adbdf563c4c4ba32526244a2a092

Contents?: true

Size: 453 Bytes

Versions: 2

Compression:

Stored size: 453 Bytes

Contents

module Popularity
  class Medium < Crawler
    stats :recommends

    def recommends
      response_json["payload"]["value"]["count"]
    end

    def valid?
      host == 'medium.com'
    end

    protected

    def medium_id
      @url.split("/").last.split("-").last
    end

    def request_url
      "https://medium.com/p/#{medium_id}/upvotes"
    end

    def response_json
      JSON.parse(response.sub("])}while(1);</x>", ""))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
popularity-0.3.0 lib/popularity/networks/medium.rb
popularity-0.2.1 lib/popularity/networks/medium.rb