class AmbientSpec::Player
Constants
- FIFTHS
- PATCHES
- PATH_TO_FILES
Public Instance Methods
sing(status=:pass)
click to toggle source
# File lib/ambient_spec/player.rb, line 11 def sing(status=:pass) if status == :pass return unless should_play? folder = PATCHES.sample filename = FIFTHS.sample system("afplay #{PATH_TO_FILES}/#{folder}/#{filename}.wav &>/dev/null &") increment_timer else system("afplay #{PATH_TO_FILES}/failure/failure.wav &>/dev/null &") end end
Private Instance Methods
increment_timer()
click to toggle source
# File lib/ambient_spec/player.rb, line 29 def increment_timer @last_played_at = Time.now end
should_play?()
click to toggle source
# File lib/ambient_spec/player.rb, line 25 def should_play? @last_played_at.nil? || Time.now - @last_played_at > 1 end