class RandomPassword
Public Class Methods
new(randomizer = Randomizer.new)
click to toggle source
# File lib/random_password.rb, line 6 def initialize(randomizer = Randomizer.new) @randomizer = randomizer end
Public Instance Methods
generate(dictionary, num_words=1)
click to toggle source
# File lib/random_password.rb, line 10 def generate(dictionary, num_words=1) num_words.times.reduce("") do |password, _| key = @randomizer.random(dictionary.length) "#{password} #{dictionary[key]}" end.strip end