Skip to content

Instantly share code, notes, and snippets.

@champierre
Created September 17, 2013 14:47
Show Gist options
  • Select an option

  • Save champierre/6595357 to your computer and use it in GitHub Desktop.

Select an option

Save champierre/6595357 to your computer and use it in GitHub Desktop.
require "scratchrsc"
class PrintRSC < RSCWatcher
def on_broadcast(name) # when a broadcast is sent
puts "broadcast #{name}" # print it to the screen
end
def on_sensor_update(name,value) # when a variable or sensor is updated
puts "#{name} = #{value}" # print the change to the screen
if name == "test"
@test = value
end
end
def broadcast_hello # when the broadcast "hello" is sent, ignore on_broadcast and
puts "Helloを受け取りました" # greet the world,
puts "test: #{@test}"
end
end
watcher = PrintRSC.new # you can provide the host as an argument
watcher.sensor_update "connected", "1"
loop { watcher.handle_command }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment