class Popularity::RedditPost

Public Instance Methods

comments() click to toggle source
# File lib/popularity/networks/reddit_post.rb, line 13
def comments
  begin
    response_json[0]["data"]["children"][0]["data"]["num_comments"]
  rescue
    0
  end
end
name() click to toggle source
# File lib/popularity/networks/reddit_post.rb, line 28
def name
  "reddit"
end
score() click to toggle source
# File lib/popularity/networks/reddit_post.rb, line 5
def score
  begin
    response_json[0]["data"]["children"][0]["data"]["score"]
  rescue
    0
  end
end
valid?() click to toggle source
# File lib/popularity/networks/reddit_post.rb, line 21
def valid?
  return false unless host == 'reddit.com'

  path = URI.parse(@url).path
  path.split('/').delete_if { |a| a.empty? }.size < 6
end

Protected Instance Methods

request_url() click to toggle source
# File lib/popularity/networks/reddit_post.rb, line 34
def request_url
  "#{@url}.json"
end