Class: PokeAPI::Parser::EvolutionDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/pokeapi/parser/evolution_details.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ EvolutionDetails

Returns a new instance of EvolutionDetails.



9
10
11
12
13
14
15
# File 'lib/pokeapi/parser/evolution_details.rb', line 9

def initialize(data)
  @data = data.clone
  @item = @data.delete :item
  @trigger = @data.delete :trigger
  @held_item = @data.delete :held_item
  @location = @data.delete :location
end

Class Method Details

.parse(data) ⇒ Object



4
5
6
7
# File 'lib/pokeapi/parser/evolution_details.rb', line 4

def self.parse(data)
  return if data.nil?
  new(data).parse
end

Instance Method Details

#parseObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pokeapi/parser/evolution_details.rb', line 17

def parse
  {
    item: item,
    trigger: trigger,
    held_item: held_item,
    gender: @data[:gender],
    known_move: known_move,
    known_move_type: known_move_type,
    location: location,
    min_level: @data[:min_level],
    min_happiness: @data[:min_happiness],
    min_beauty: @data[:min_beauty],
    min_affection: @data[:min_affection],
    needs_overworld_rain: @data[:needs_overworld_rain],
    party_species: @data[:party_species],
    party_type: @data[:party_type],
    relative_physical_stats: @data[:relative_physical_stats],
    time_of_day: time_of_day,
    trade_species: @data[:trade_species],
    turn_upside_down: @data[:turn_upside_down],
  }
end