Class: TheGamesDB::Game

Inherits:
Object
  • Object
show all
Includes:
SAXMachine
Defined in:
lib/the_games_db/game.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#feedObject

Returns the value of attribute feed.



26
27
28
# File 'lib/the_games_db/game.rb', line 26

def feed
  @feed
end

Class Method Details

.find(id) ⇒ Object



33
34
35
36
37
# File 'lib/the_games_db/game.rb', line 33

def self.find(id)
  feed = TheGamesDB::Feed.fetch_and_parse('GetGame.php', :id => id)

  feed.games.first || raise(TheGamesDB::Exception::GameNotFound.new id)
end

.search(params = {}) ⇒ Object



28
29
30
31
# File 'lib/the_games_db/game.rb', line 28

def self.search(params = {})
  feed = TheGamesDB::Feed.fetch_and_parse('GetGamesList.php', params)
  feed.games
end

Instance Method Details

#release_dateObject



39
40
41
42
43
44
# File 'lib/the_games_db/game.rb', line 39

def release_date
  return unless @release_date

  month, day, year = @release_date.split('/').map(&:to_i)
  Date.civil year, month, day
end