class NintendoEshop::GamesList
Attributes
games[RW]
title[RW]
Public Class Methods
by_title(title)
click to toggle source
# File lib/nintendo_eshop/games_list.rb, line 25 def self.by_title(title) instance = new(title) instance.refresh end
new(title)
click to toggle source
# File lib/nintendo_eshop/games_list.rb, line 8 def initialize(title) self.title = title end
Public Instance Methods
each() { |game| ... }
click to toggle source
# File lib/nintendo_eshop/games_list.rb, line 19 def each games.each do |game| yield(game) end end
refresh()
click to toggle source
# 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
Private Instance Methods
body()
click to toggle source
# File lib/nintendo_eshop/games_list.rb, line 32 def body { "query": title.to_s, "restrictSearchableAttributes": [ "title" ] } end
refresh_list_objects(objects)
click to toggle source
# File lib/nintendo_eshop/games_list.rb, line 45 def refresh_list_objects(objects) objects.map do |object| game = Game.new(id: object.dig(:nsuid)) game.send(:refresh_object, object) game end end
resource_path()
click to toggle source
# File lib/nintendo_eshop/games_list.rb, line 41 def resource_path "/1/indexes/noa_aem_game_en_us/query".freeze end