Class: SonicPi

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

Constant Summary collapse

RUN_COMMAND =
"/run-code"
STOP_COMMAND =
"/stop-all-jobs"
SERVER =
'localhost'
PORT =
4557
GUI_ID =
'SONIC_PI_CLI'

Instance Method Summary collapse

Instance Method Details

#run(command) ⇒ Object


13
14
15
# File 'lib/sonic_pi.rb', line 13

def run(command)
  send_command(RUN_COMMAND, command)
end

#stopObject


17
18
19
# File 'lib/sonic_pi.rb', line 17

def stop
  send_command(STOP_COMMAND)
end

#test_connection!Object


21
22
23
24
25
26
27
28
29
# File 'lib/sonic_pi.rb', line 21

def test_connection!
  begin
    socket = UDPSocket.new
    socket.bind(nil, PORT)
    abort("ERROR: Sonic Pi is not listening on #{PORT} - is it running?")
  rescue
    # everything is good
  end
end