Class: Oakdex::Pokemon::Factory
- Inherits:
-
Object
- Object
- Oakdex::Pokemon::Factory
- Defined in:
- lib/oakdex/pokemon/factory.rb
Overview
Creates Pokemon instance and prefills attributes
Constant Summary collapse
- REQUIRED_ATTRIBUTES =
%i[exp gender ability_id nature_id hp iv ev moves]
- OPTIONAL_ATTRIBUTES =
%i[ original_trainer primary_status_condition wild item_id amie friendship ]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(species, options = {}) ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize(species, options = {}) ⇒ Factory
Returns a new instance of Factory.
26 27 28 29 |
# File 'lib/oakdex/pokemon/factory.rb', line 26 def initialize(species, = {}) @species = species @options = end |
Class Method Details
.create(species, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/oakdex/pokemon/factory.rb', line 16 def create(species, = {}) factory = new(species, ) attributes = Hash[(REQUIRED_ATTRIBUTES + OPTIONAL_ATTRIBUTES).map do |attr| [attr, factory.send(attr)] end] Pokemon.new(species.names['en'], attributes) end |