8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/geordi/hint.rb', line 8
def did_you_know(hints)
settings_probability = Settings.new.hint_probability
default_probability = (Util.testing? ? 0 : 10) should_print_hint = Random.new.rand(100) <= (settings_probability || default_probability)
generated_hints = hints.map(&method(:generate))
if generated_hints.any? && should_print_hint
puts
puts generated_hints.sample
puts "You can configure the probability for these hints by setting hint_probability to a unitless percent number in #{Settings::GLOBAL_SETTINGS_FILE_NAME}" unless settings_probability
end
generated_hints
end
|