Sha256: dc7cea14b72ad0a5da445ae619baddcf20e10430ad10d61c2a5def4bd5b2e023
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Popularity class RedditPost < Crawler def score begin response_json[0]["data"]["children"][0]["data"]["score"] rescue 0 end end def comments begin response_json[0]["data"]["children"][0]["data"]["num_comments"] rescue 0 end end def as_json(options = {}) { "comments" => comments, "score" => score } end def total comments + score end def valid? return false unless host == 'reddit.com' path = URI.parse(@url).path path.split('/').delete_if { |a| a.empty? }.size < 6 end def name "reddit" end protected def request_url "#{@url}.json" end end class RedditResult < RedditPost # A stubbed out version of a RedditPost so RedditShare can # stub in the json response it already has def initialize(url, r) super(url) @response = r self end def has_response? true end def valid? URI.parse(@url).host end def fetch false end def fetch_async false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
popularity-0.1.1 | lib/popularity/networks/reddit_post.rb |