Class: RandomPerson::Names::AmericanSuffix
- Inherits:
-
RandomPerson::Name
- Object
- RandomPerson::Name
- RandomPerson::Names::AmericanSuffix
- Defined in:
- lib/randomperson/Names/AmericanSuffix.rb
Instance Attribute Summary
Attributes inherited from RandomPerson::Name
#formats, #formats_ratiod, #names
Instance Method Summary collapse
- #execute(person) ⇒ Object
-
#initialize ⇒ AmericanSuffix
constructor
A new instance of AmericanSuffix.
Constructor Details
#initialize ⇒ AmericanSuffix
Returns a new instance of AmericanSuffix.
6 7 8 9 |
# File 'lib/randomperson/Names/AmericanSuffix.rb', line 6 def initialize @names = [ 'Jr.', ''] + %w( I II III IV V Sr. ) @formats_ratiod = [ 0, 1..93, 94, 95, 96, 97, 98, 99] end |
Instance Method Details
#execute(person) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/randomperson/Names/AmericanSuffix.rb', line 11 def execute( person) r = rand(99) if person.age > 17 r += 1 #Jr can't happen end i = @formats_ratiod.index_in_range( r ) return @names[i] end |