Class: Popularity::RedditComment
- Inherits:
-
Crawler
- Object
- Crawler
- Popularity::RedditComment
show all
- Defined in:
- lib/popularity/networks/reddit_comment.rb
Instance Attribute Summary
Attributes inherited from Crawler
#url
Instance Method Summary
collapse
Methods inherited from Crawler
#as_json, #async_done?, #fetch, #fetch_async, #has_response?, #host, #initialize, property_names, #response, #response_json, stats, #total
Instance Method Details
#name ⇒ Object
16
17
18
|
# File 'lib/popularity/networks/reddit_comment.rb', line 16
def name
"reddit"
end
|
#score ⇒ Object
5
6
7
|
# File 'lib/popularity/networks/reddit_comment.rb', line 5
def score
response_json[1]["data"]["children"][0]["data"]["score"]
end
|
#valid? ⇒ Boolean
9
10
11
12
13
14
|
# File 'lib/popularity/networks/reddit_comment.rb', line 9
def valid?
return false unless host == 'reddit.com'
path = URI.parse(@url).path
path.split('/').delete_if { |a| a.empty? }.size == 6
end
|