Class: Game

Inherits:
Object
  • Object
show all
Defined in:
lib/game_gem/game.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Game

Returns a new instance of Game.



6
7
8
# File 'lib/game_gem/game.rb', line 6

def initialize(attributes)
  attributes.each { |key, value| self.send("#{key}=", value) }
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/game_gem/game.rb', line 2

def name
  @name
end

#priceObject

Returns the value of attribute price.



2
3
4
# File 'lib/game_gem/game.rb', line 2

def price
  @price
end

Class Method Details

.allObject



14
15
16
# File 'lib/game_gem/game.rb', line 14

def self.all
  @@all
end

.mass_create(games) ⇒ Object



10
11
12
# File 'lib/game_gem/game.rb', line 10

def self.mass_create(games)
  games.each { |game| @@all << Game.new(game) if !game[:name].empty? }
end