Class: PokemonNameGenerator::Corpus::Data
- Inherits:
-
Object
- Object
- PokemonNameGenerator::Corpus::Data
- Defined in:
- lib/pokemon_name_generator/corpus/data.rb
Constant Summary collapse
- DATA_FILE_PATH =
File.("../../../../data/pokemon.txt", __FILE__)
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(file: DATA_FILE_PATH) ⇒ Data
constructor
A new instance of Data.
- #load_pokemon_names ⇒ Object
Constructor Details
#initialize(file: DATA_FILE_PATH) ⇒ Data
8 9 10 |
# File 'lib/pokemon_name_generator/corpus/data.rb', line 8 def initialize(file: DATA_FILE_PATH) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/pokemon_name_generator/corpus/data.rb', line 6 def file @file end |
Instance Method Details
#load_pokemon_names ⇒ Object
12 13 14 15 16 |
# File 'lib/pokemon_name_generator/corpus/data.rb', line 12 def load_pokemon_names File.readlines(file, chomp: true) .map { |line| line[5..] } # drop the number .map(&:downcase) end |