# frozen_string_literal: true module PKParse # Define a PKParse::Pokemon to keep Rails' model distinct and allow this to be # updated independently without fear of breaking the app. class Pokemon attr_accessor :pokedex_number, :nickname, :raw_nickname, :raw_pokemon def initialize(attributes = {}) attributes.each do |attr, v| send("#{attr}=", v) rescue StandardError PKParse.logger.error("Received unexpected attribute '#{attr}'") nil end end def to_h { pokedex_number: pokedex_number, nickname: nickname, raw_nickname: raw_nickname, raw_pokemon: raw_pokemon, } end def to_json(*_args) to_h end end end