| 123456789101112131415161718192021222324252627282930 |
- # 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
- 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
|