class PokeAPI::Parser::Species
Constants
- HEX_COLORS
Public Class Methods
new(data)
click to toggle source
# File lib/pokeapi/parser/species.rb, line 21 def initialize(data) @data = data.clone @flavor_text_entries = @data.delete :flavor_text_entries @color_name = @data[:color][:name] end
parse(data)
click to toggle source
# File lib/pokeapi/parser/species.rb, line 17 def self.parse(data) new(data).parse end
Public Instance Methods
parse()
click to toggle source
# File lib/pokeapi/parser/species.rb, line 27 def parse { id: @data[:id], color_name: @color_name, color_hex: HEX_COLORS[@color_name.to_sym], shape: @data[:shape][:name], flavor_text_entries: flavor_text_entries, evolution_chain_id: @data[:evolution_chain][:url].split("/").last, } end
Private Instance Methods
flavor_text_entries()
click to toggle source
# File lib/pokeapi/parser/species.rb, line 40 def flavor_text_entries @flavor_text_entries.map do |text_entry| { text: text_entry[:flavor_text], language: text_entry[:language][:name], version: text_entry[:version][:name] } end end