Class: Pokeedex::Pokemon::Decorators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/pokeedex/pokemon/decorators/base.rb

Overview

Base class for the Pokemon decorators This class is used to decorate the Pokemon object with additional information and format it for display to the user in the CLI or other interfaces. The class is initialized with a Pokemon object and has a method to return the decorated Pokemon object as a string for display to the user in the CLI or other interfaces with the following information:

For example

Número: 1
Nombre: Bulbasaur
Descripción: Tras nacer, crece alimentándose durante un tiempo de los nutrientes que contiene el bulbo de su lomo.
Altura: 0.7 m
Peso: 6.9 kg
Categoría:
Habilidades: Espesura
Genero: Macho, Hembra
Tipo: Planta, Veneno
Habilidades: Fuego, Hielo, Volador, Psíquico

Puntos de base
%%%------------ PS
%%%------------ Ataque
%%%------------ Defensa
%%%%----------- Ataque Especial
%%%%----------- Defensa Especial
%%%------------ Velocidad

Constant Summary collapse

GENDER =
{
  'male' => 'Macho',
  'female' => 'Hembra'
}.freeze
MAXIMUM_STAT_VALUE =
15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pokemon) ⇒ Base

Returns a new instance of Base.



40
41
42
# File 'lib/pokeedex/pokemon/decorators/base.rb', line 40

def initialize(pokemon)
  @pokemon = pokemon
end

Instance Attribute Details

#pokemonObject (readonly)

The Pokemon object to decorate. Receive a Pokemon object to decorate of Pokeedex::Pokemon::Model::Base class



31
32
33
# File 'lib/pokeedex/pokemon/decorators/base.rb', line 31

def pokemon
  @pokemon
end

Instance Method Details

#to_sObject

Return the decorated Pokemon object as a string for display to the user in the CLI or other interfaces



46
47
48
# File 'lib/pokeedex/pokemon/decorators/base.rb', line 46

def to_s
  decorate
end