Class: AmbientSpec::Player
- Inherits:
-
Object
- Object
- AmbientSpec::Player
- Defined in:
- lib/ambient_spec/player.rb
Instance Attribute Summary collapse
-
#counter ⇒ Object
Returns the value of attribute counter.
Instance Method Summary collapse
Instance Attribute Details
#counter ⇒ Object
Returns the value of attribute counter.
7 8 9 |
# File 'lib/ambient_spec/player.rb', line 7 def counter @counter end |
Instance Method Details
#fifths ⇒ Object
9 10 11 |
# File 'lib/ambient_spec/player.rb', line 9 def fifths ["c", "g", "d", "a", "e", "b", "f"] end |
#increment_counter ⇒ Object
25 26 27 |
# File 'lib/ambient_spec/player.rb', line 25 def increment_counter self.counter ||= 0; self.counter += 1 end |
#path_to_files ⇒ Object
29 30 31 |
# File 'lib/ambient_spec/player.rb', line 29 def path_to_files @path_to_files ||= File.join(File.dirname(File.(__FILE__)), 'sounds') end |
#sing(status = :pass) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ambient_spec/player.rb', line 13 def sing(status=:pass) increment_counter # return unless counter % 3 == 1 || status == :fail if status == :pass folder = %w{breathy dark ghost harp piano plasma swirl waves}.sample filename = fifths.sample system("afplay #{path_to_files}/#{folder}/#{filename}.wav &>/dev/null &") else system("afplay #{path_to_files}/failure/failure.wav &>/dev/null &") end end |