Class: NintendoEshop::GamesList
- Inherits:
-
APIRequest
- Object
- APIRequest
- NintendoEshop::GamesList
- Includes:
- Enumerable
- Defined in:
- lib/nintendo_eshop/games_list.rb
Instance Attribute Summary collapse
-
#games ⇒ Object
Returns the value of attribute games.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(title) ⇒ GamesList
constructor
A new instance of GamesList.
- #refresh ⇒ Object
Constructor Details
#initialize(title) ⇒ GamesList
Returns a new instance of GamesList.
8 9 10 |
# File 'lib/nintendo_eshop/games_list.rb', line 8 def initialize(title) self.title = title end |
Instance Attribute Details
#games ⇒ Object
Returns the value of attribute games.
6 7 8 |
# File 'lib/nintendo_eshop/games_list.rb', line 6 def games @games end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/nintendo_eshop/games_list.rb', line 5 def title @title end |
Class Method Details
.by_title(title) ⇒ Object
25 26 27 28 |
# File 'lib/nintendo_eshop/games_list.rb', line 25 def self.by_title(title) instance = new(title) instance.refresh end |
Instance Method Details
#each ⇒ Object
19 20 21 22 23 |
# File 'lib/nintendo_eshop/games_list.rb', line 19 def each games.each do |game| yield(game) end end |
#refresh ⇒ Object
12 13 14 15 16 17 |
# File 'lib/nintendo_eshop/games_list.rb', line 12 def refresh response = request(:post, to_json: body) result = response.dig(:hits) self.games = refresh_list_objects(result) self end |