Class: RAWG::Game

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/rawg/game.rb

Instance Method Summary collapse

Methods included from Utils

#assign_attributes, included

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Game

Returns a new instance of Game.

Yields:

  • (_self)

Yield Parameters:

  • _self (RAWG::Game)

    the object that the method was called on



13
14
15
16
17
# File 'lib/rawg/game.rb', line 13

def initialize(options = {})
  @client = options[:client] || RAWG::Client.new
  assign_attributes(options)
  yield self if block_given?
end

Instance Method Details

#from_api_response(response) ⇒ Object



19
20
21
22
# File 'lib/rawg/game.rb', line 19

def from_api_response(response)
  assign_attributes(response)
  self
end

#suggested(options) ⇒ Object



24
25
26
27
28
29
# File 'lib/rawg/game.rb', line 24

def suggested(options)
  response = client.game_suggest(@id, options)
  RAWG::Collection
    .new(RAWG::Game, client: client)
    .from_api_response(response)
end