Class: RandomPerson::Names::BritishSuffix

Inherits:
RandomPerson::Name show all
Defined in:
lib/randomperson/Names/BritishSuffix.rb

Instance Attribute Summary

Attributes inherited from RandomPerson::Name

#formats, #formats_ratiod, #names

Instance Method Summary collapse

Constructor Details

#initializeBritishSuffix

Returns a new instance of BritishSuffix.



6
7
8
9
10
11
12
13
14
# File 'lib/randomperson/Names/BritishSuffix.rb', line 6

def initialize
  @formats = {
  
   }
   
  @formats_ratiod = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9..59, 59..159]
  
  @names = %w( OBE, MBE, GBE, KBE, DBE, CBE, JP, GM, PhD BSc, BA )
end

Instance Method Details

#execute(person) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/randomperson/Names/BritishSuffix.rb', line 16

def execute( person )
  retval = nil
  r = rand(999)      
  unless person.age < 17 #sorry kids, but you ain't gonna get these
    i = @formats_ratiod.index_in_range( r )
    retval = @names[i] unless i.nil?
  end

  return retval 
end