in Ruby

Using the Apple remote in Ruby

Apple infrared remote controlAfter playing with iremoted and Ruby’s IO.popen I guess I am convinced that Ruby really works as a glue on many levels.

So, using iremoted and capture Apple remote commands in the terminal it is trivial to use the remote to control a Ruby application. Of course, calling OS commands isn’t limited to Ruby.

Here is a minimal dungeon game which you control with the apple remote. If you ever manage to find your way out I would be surprised…

IO.popen (“/Applications/iremoted”) { |f|

x = y = 0

puts “You are standing in an open field west of a white house, with a boarded front door…”

while (line = f.gets.chomp)
if line == “Plus released”
y += 1

if line == “Minus released”
y -= 1

if line == “Previous released”
x -= 1

if line == “Next released”
x += 1

puts “You are at coordinate #{x}, #{y}.”

Who will be first to create a terminal based media center application using Ruby? With some more glue from RubyOSA (the Ruby/AppleEvent Bridge) it should’t be that hard.

  1. This looks awesome, but, every event makes iremoted put two lines, so the puts “you are at coordinates…” should only happen everyother line. You need a matcher or a counter

Comments are closed.