Ruby DSL for Apple Remotes

I was curious about RubyCocoa and decided to play around a bit. I came across this article on rubycocoa.com about the apple remote and ruby. I got it working and boredom took over… so I decided to wrap it with a simple DSL. It seems pretty pointless, although switching OSX spaces with it was fun…

How does it look?

More examples are on the GitHub project page linked below, but here is a small overview.

require 'lib/apple_remote'

play do
  puts "I'm playing... (Playing? #{playing?})"
end

pause do
  puts "I'm paused... (Playing? #{playing?})"
end

menu do
  if playing?
    puts "Do something with the menu while we're in 'play' state"
  else
    puts "Do something with the menu while we're not in the 'play' state"
  end
end

Tons of fun :)

Code

Ruby Apple Remote DSL project on GitHub




Comments

No comments yet.

Add Yours

  • Author Avatar

    YOU


Comment Arrow



About Author

Rob Hurring

Ruby, Rails, PHP, bash... oh my!