Class: MetacriticGames::Platform
- Inherits:
-
Object
- Object
- MetacriticGames::Platform
- Extended by:
- Concerns::Findable::ClassMethods, Concerns::Nameable::ClassMethods, Concerns::Persistable::ClassMethods
- Includes:
- Concerns::Persistable::InstanceMethods
- Defined in:
- lib/platform.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#games ⇒ Object
Returns the value of attribute games.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #add_game(game) ⇒ Object
- #genres ⇒ Object
-
#initialize ⇒ Platform
constructor
A new instance of Platform.
Methods included from Concerns::Nameable::ClassMethods
Methods included from Concerns::Findable::ClassMethods
find_by_name, find_or_create_by_name
Methods included from Concerns::Persistable::ClassMethods
Methods included from Concerns::Persistable::InstanceMethods
Constructor Details
#initialize ⇒ Platform
Returns a new instance of Platform.
16 17 18 |
# File 'lib/platform.rb', line 16 def initialize self.games = [] end |
Instance Attribute Details
#games ⇒ Object
Returns the value of attribute games.
8 9 10 |
# File 'lib/platform.rb', line 8 def games @games end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/platform.rb', line 8 def name @name end |
Class Method Details
.all ⇒ Object
12 13 14 |
# File 'lib/platform.rb', line 12 def self.all @@all end |
.create_platforms(platform_array) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/platform.rb', line 20 def self.create_platforms(platform_array) platform_array.each do |platform| MetacriticGames::CLI..increment self.find_or_create_by_name(platform) end self.all end |
Instance Method Details
#add_game(game) ⇒ Object
28 29 30 31 |
# File 'lib/platform.rb', line 28 def add_game(game) game.platform << self unless game.platform.include? self self.games << game unless self.games.include?(game) end |
#genres ⇒ Object
33 34 35 |
# File 'lib/platform.rb', line 33 def genres self.games.collect {|game| game.genre}.uniq end |