Class: TuneYard::BasePlayer

Inherits:
SonicPi::Spider
  • Object
show all
Includes:
SonicPi::Mods::Sound, SonicPi::SpiderAPI
Defined in:
lib/tune_yard/player.rb

Direct Known Subclasses

DefaultPlayer

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/tune_yard/player.rb', line 38

def method_missing name, *args
  if @_outer_binding.local_variable_defined? name
    @_outer_binding.local_variable_get name
  else
    @_outer_binding.send name, *args
  end
end

Instance Method Details

#run(&block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tune_yard/player.rb', line 22

def run &block
  # TODO: there's a definite race condition here
  @_outer_binding = block.binding

  code = <<-CODE
    use_arg_checks true
    use_debug true
    #{block.to_source strip_enclosure: true}
  CODE
  __spider_eval code, workspace: __FILE__
end

#stopObject



34
35
36
# File 'lib/tune_yard/player.rb', line 34

def stop
  __stop_jobs
end