Class: Geordi::Hint

Inherits:
Object
  • Object
show all
Defined in:
lib/geordi/hint.rb

Class Method Summary collapse

Class Method Details

.did_you_know(hints) ⇒ Object



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) # Percent
  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