Class: TinyHNews::TopStories
- Inherits:
-
Object
- Object
- TinyHNews::TopStories
- Defined in:
- lib/tiny_hnews/top_stories.rb
Instance Attribute Summary collapse
-
#stories ⇒ Object
readonly
Returns the value of attribute stories.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(number_of_stories: 10, comments_depth: 2, comments_limit: 20) ⇒ TopStories
constructor
A new instance of TopStories.
Constructor Details
#initialize(number_of_stories: 10, comments_depth: 2, comments_limit: 20) ⇒ TopStories
Returns a new instance of TopStories.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/tiny_hnews/top_stories.rb', line 5 def initialize( number_of_stories: 10, comments_depth: 2, comments_limit: 20 ) @number_of_stories = number_of_stories @comments_depth = comments_depth @comments_limit = comments_limit @stories = [] end |
Instance Attribute Details
#stories ⇒ Object (readonly)
Returns the value of attribute stories.
3 4 5 |
# File 'lib/tiny_hnews/top_stories.rb', line 3 def stories @stories end |
Instance Method Details
#fetch ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tiny_hnews/top_stories.rb', line 16 def fetch top_stories = TinyHNews::API.topstories.first(@number_of_stories) @stories = top_stories.map do |story_id| TinyHNews::Story.new( id: story_id, comments_depth: @comments_depth, comments_limit: @comments_limit ).wrap end self end |