Method: NameGenerator#select_link
- Defined in:
- lib/gemwarrior/misc/name_generator.rb
#select_link(chain, key) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/gemwarrior/misc/name_generator.rb', line 156 def select_link(chain, key) len = chain['table_len'][key] idx = (rand() * len).floor t = 0 chain[key].each do |chain_key, chain_value| t += chain_value return chain_key if (idx < t) end return '-' end |