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
- @@request =
Request.new
Class Method Summary collapse
- .new_stories(num = 5) ⇒ Object
- .story_comments(story_id) ⇒ Object
- .top_job_stories(num = 5) ⇒ Object
- .top_stories(num = 5) ⇒ Object
- .user_stories(user_id, num = 5) ⇒ Object
Class Method Details
.new_stories(num = 5) ⇒ Object
10 11 12 |
# File 'lib/hack3rnews.rb', line 10 def new_stories(num = 5) stories('newstories', num) end |
.story_comments(story_id) ⇒ Object
23 24 25 26 |
# File 'lib/hack3rnews.rb', line 23 def story_comments(story_id) story = item('item', story_id) items(story['kids'] || []) end |
.top_job_stories(num = 5) ⇒ Object
28 29 30 |
# File 'lib/hack3rnews.rb', line 28 def top_job_stories(num = 5) top_items(stories('jobstories'), 'score').last(num) end |
.top_stories(num = 5) ⇒ Object
14 15 16 |
# File 'lib/hack3rnews.rb', line 14 def top_stories(num = 5) stories('topstories', num) end |
.user_stories(user_id, num = 5) ⇒ Object
18 19 20 21 |
# File 'lib/hack3rnews.rb', line 18 def user_stories(user_id, num = 5) user = item('user', user_id) items(user['submitted'].first(num) || []) end |