Class: UpcomingVideoGames::Game
- Inherits:
-
Object
- Object
- UpcomingVideoGames::Game
- Defined in:
- lib/upcoming_video_games/game.rb
Constant Summary collapse
- @@games =
[]
Instance Attribute Summary collapse
-
#console ⇒ Object
Returns the value of attribute console.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#purchase_link ⇒ Object
Returns the value of attribute purchase_link.
-
#release_date ⇒ Object
Returns the value of attribute release_date.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_game_details(details) ⇒ Object
-
#initialize(game_hash) ⇒ Game
constructor
A new instance of Game.
Constructor Details
#initialize(game_hash) ⇒ Game
Returns a new instance of Game.
6 7 8 9 |
# File 'lib/upcoming_video_games/game.rb', line 6 def initialize(game_hash) game_hash.each {|key, value| self.send(("#{key}="), value)} @@games << self end |
Instance Attribute Details
#console ⇒ Object
Returns the value of attribute console.
2 3 4 |
# File 'lib/upcoming_video_games/game.rb', line 2 def console @console end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/upcoming_video_games/game.rb', line 2 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/upcoming_video_games/game.rb', line 2 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/upcoming_video_games/game.rb', line 2 def price @price end |
#purchase_link ⇒ Object
Returns the value of attribute purchase_link.
2 3 4 |
# File 'lib/upcoming_video_games/game.rb', line 2 def purchase_link @purchase_link end |
#release_date ⇒ Object
Returns the value of attribute release_date.
2 3 4 |
# File 'lib/upcoming_video_games/game.rb', line 2 def release_date @release_date end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/upcoming_video_games/game.rb', line 2 def url @url end |
Class Method Details
.create_by_each_game(scraped_games) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/upcoming_video_games/game.rb', line 12 def self.create_by_each_game(scraped_games) scraped_games.each do |game| #write a comment to explain release year self.new(game) unless game[:release_date] < (DateTime.now) rescue nil end end |
.games ⇒ Object
19 20 21 |
# File 'lib/upcoming_video_games/game.rb', line 19 def self.games @@games.sort_by! {|game_obj| game_obj.release_date} end |
Instance Method Details
#add_game_details(details) ⇒ Object
23 24 25 26 |
# File 'lib/upcoming_video_games/game.rb', line 23 def add_game_details(details) details.each {|key, value| self.send(("#{key}="), value)} self end |