Module: RandomPerson::Loader::InstanceMethods 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.

Instance methods

Instance Method Summary collapse

Instance Method Details

#addklass(klass, patterns = nil) ⇒ 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.

TODO:

remove evil

The patterns are there to stop other files being added by accident. and to load the right names into the right instance var

Parameters:

  • klass (#to_constant)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/randomperson/loader.rb', line 45

def addklass( klass, patterns=nil )
  patterns ||=  [
                  ["Male",'First'],
                  ["Female", "First"],
                  ['Last'], ['Prefix'],
                  ['Suffix']
                ]
  patterns.each do |ps|
    if ps.all?{|p| klass.name =~ /#{p}/ }
      send "#{ps.join.downcase}=", klass.new
      loaded_classes.store ps.join.downcase.to_sym, klass.name.split("::").last.scan( /[A-Z][a-z]+/ ).flatten.join("_")
    end # if
  end
  klass
end