Class: RandomPerson::Names::AmericanSuffix

Inherits:
RandomPerson::Name show all
Defined in:
lib/randomperson/names/american-suffix.rb

Constant Summary collapse

Names =
[ 'Jr.', ''] + %w( I II III IV V Sr. )

Instance Attribute Summary

Attributes inherited from RandomPerson::Name

#formats, #formats_ratiod, #names, #possibles

Instance Method Summary collapse

Methods included from Outputter

included

Constructor Details

#initializeAmericanSuffix

Returns a new instance of AmericanSuffix.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/randomperson/names/american-suffix.rb', line 13

def initialize
  @names = Names
  @formats = nil
  @formats_ratiod = [ 0..0, 1..93, 94..94, 95..95, 96..96, 97..97, 98..98, 99..99]
  @possibles = Hash[ @formats_ratiod.zip @names ]
  
  on_execute do |person|
    r = rand(99)      
    if person.age > 17
      r += 1 #Jr can't happen and Snr can
    end

    @possibles.each_pair{|k,v| break v if k === r }
  end #

  super
end