Sha256: b2d1b0846a0a7122e60cd833851f201e6231a82148753820ec6a9cdf187d48a5
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
module Popularity class RedditPost < Crawler stats :score, :comments 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 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 stats :score, :comments def initialize(url, r) super(url) @url = url @response = r self end def has_response? true end def reddit_url @url end def valid? URI.parse(@url).host end def fetch false end def fetch_async false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
popularity-0.3.0 | lib/popularity/networks/reddit_post.rb |
popularity-0.2.1 | lib/popularity/networks/reddit_post.rb |