Class: HackerNew
- Inherits:
-
Object
- Object
- HackerNew
- Defined in:
- lib/hack3rnews.rb
Constant Summary collapse
- URL =
'https://hacker-news.firebaseio.com/v0/'.freeze
- JSON_FORMAT =
'/.json?print=pretty'.freeze
Class Method Summary collapse
- .new_stories(num = 5) ⇒ Object
- .story_comments(story) ⇒ Object
- .top_job_stories(num = 5) ⇒ Object
- .top_stories(num = 5) ⇒ Object
- .user_stories(user, num = 5) ⇒ Object
Class Method Details
.new_stories(num = 5) ⇒ Object
9 10 11 |
# File 'lib/hack3rnews.rb', line 9 def new_stories(num = 5) capture_stories('newstories', num) end |
.story_comments(story) ⇒ Object
21 22 23 |
# File 'lib/hack3rnews.rb', line 21 def story_comments(story) capture_item_kids('item', item_id: story, kind: 'kids') end |
.top_job_stories(num = 5) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/hack3rnews.rb', line 25 def top_job_stories(num = 5) job_scores = [] request_bunch('jobstories').each do |job_id| job_scores << request_item('item', job_id) end job_scores.sort_by! { |hsh| hsh["score"] } job_scores.last(num).reverse end |
.top_stories(num = 5) ⇒ Object
13 14 15 |
# File 'lib/hack3rnews.rb', line 13 def top_stories(num = 5) capture_stories('topstories', num) end |
.user_stories(user, num = 5) ⇒ Object
17 18 19 |
# File 'lib/hack3rnews.rb', line 17 def user_stories(user, num = 5) capture_item_kids('user', num: num, item_id: user, kind: 'submitted') end |