Sha256: fa2e7cc28a5b101ca5a71772cb842ccad3a5544a728e07efd8860b258e1a4306

Contents?: true

Size: 553 Bytes

Versions: 3

Compression:

Stored size: 553 Bytes

Contents

module Popularity
  class Medium < Crawler
    def recommends
      response_json["payload"]["value"]["count"]
    end

    def as_json(options = {})      
      {"recommends" => recommends}
    end

    def total
      recommends
    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

3 entries across 3 versions & 1 rubygems

Version Path
popularity-0.1.1 lib/popularity/networks/medium.rb
popularity-0.1.0 lib/popularity/networks/medium.rb
popularity-0.0.1 lib/popularity/medium.rb