Class: Engagement::CommentCounter::HackerNews

Inherits:
Object
  • Object
show all
Defined in:
lib/engagement/comment_counter/hacker_news.rb

Instance Method Summary collapse

Constructor Details

#initializeHackerNews

Returns a new instance of HackerNews.



4
5
6
# File 'lib/engagement/comment_counter/hacker_news.rb', line 4

def initialize
  @client = HackerNewsSearch.new
end

Instance Method Details

#comments_count(url) ⇒ Object



8
9
10
11
12
# File 'lib/engagement/comment_counter/hacker_news.rb', line 8

def comments_count(url)
  @client.search("items", url)['results'].inject(0) { |comments_count, result|
    comments_count + result['item']['num_comments']
  }
end