Class: Pbw::Utils::Names
- Inherits:
-
Object
- Object
- Pbw::Utils::Names
- Defined in:
- lib/pbw/utils/names.rb
Instance Method Summary collapse
-
#initialize(data_file) ⇒ Names
constructor
A new instance of Names.
- #random_name ⇒ Object
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_name ⇒ Object
14 15 16 |
# File 'lib/pbw/utils/names.rb', line 14 def random_name @list.sample end |