Class: Pbw::Utils::Names

Inherits:
Object
  • Object
show all
Defined in:
lib/pbw/utils/names.rb

Instance Method Summary collapse

Constructor Details

#initialize(data_file) ⇒ Names

Returns a new instance of Names.



4
5
6
7
8
9
10
11
12
# File 'lib/pbw/utils/names.rb', line 4

def initialize(data_file)
  @list = []
  File.open(data_file, 'r') do |file|
    while line = file.gets do
      @list << line.strip.titleize
    end
  end
  @list
end

Instance Method Details

#random_nameObject



14
15
16
# File 'lib/pbw/utils/names.rb', line 14

def random_name
  @list.sample
end