Class: RandomPerson::Names::BritishSuffix
- Inherits:
-
RandomPerson::Name
- Object
- RandomPerson::Name
- RandomPerson::Names::BritishSuffix
- Defined in:
- lib/randomperson/names/british-suffix.rb
Constant Summary collapse
- Names =
%w( OBE MBE GBE KBE DBE CBE JP GM PhD BSc BA )
Instance Attribute Summary
Attributes inherited from RandomPerson::Name
#formats, #formats_ratiod, #names, #possibles
Instance Method Summary collapse
-
#initialize ⇒ BritishSuffix
constructor
A new instance of BritishSuffix.
Methods included from Outputter
Constructor Details
#initialize ⇒ BritishSuffix
Returns a new instance of BritishSuffix.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/randomperson/names/british-suffix.rb', line 13 def initialize @names = Names @formats = nil @formats_ratiod = [ 0..0, 1..1, 2..2, 3..3, 4..4, 5..5, 6..6, 7..7, 8..8, 9..59, 59..159] @possibles = Hash[ @formats_ratiod.zip @names ] on_execute do |person| unless person.age <= 16 r = rand(@formats_ratiod.last.end + 1 ) @possibles.each_pair{|k,v| break v if k === r } else "" end end super end |