Module: RandomPerson::Loader::InstanceMethods

Defined in:
lib/randomperson/loader.rb

Instance Method Summary collapse

Instance Method Details

#addklass(klass, patterns = [["Male",'First'],["Female", "First"], ['Last'], ['Prefix'], ['Suffix']]) ⇒ Object

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)


42
43
44
45
46
47
48
49
50
# File 'lib/randomperson/loader.rb', line 42

def addklass( klass, patterns=[["Male",'First'],["Female", "First"], ['Last'], ['Prefix'], ['Suffix']] )

  patterns.each do |ps|
    if ps.all?{|p| klass =~ /#{p}/ }
      instance_variable_set( "@#{ps.join.downcase}", klass.to_constant.new)
    end # if
  end
  klass
end