Module: RandomPerson::Loader::ClassMethods Private

Defined in:
lib/randomperson/loader.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class methods

Instance Method Summary collapse

Instance Method Details

#load_names(opts = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads the names, unsurprisingly.



16
17
18
19
20
21
22
23
# File 'lib/randomperson/loader.rb', line 16

def load_names( opts={} )
  opts = { patterns: ['*.rb'], lib_dir: File.dirname(__FILE__) }.merge( opts )
  
  fulls = opts[:patterns].map do |pattern|
    full_pattern = File.join( opts[:lib_dir], 'names', pattern )
  end
   Dir.glob( fulls )
end

#translate(file_name, prefix = "RandomPerson::Names::") ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Changes the file name into a string useable as a constant class name



27
28
29
# File 'lib/randomperson/loader.rb', line 27

def translate( file_name, prefix="RandomPerson::Names::" )
  "#{prefix}#{File.basename( file_name, ".rb" ).split("-").map(&:capitalize).join}"
end