Skip to content

Instantly share code, notes, and snippets.

View Amokrane's full-sized avatar
🎯
Focusing

Amokrane Chentir Amokrane

🎯
Focusing
View GitHub Profile
@Amokrane
Amokrane / method_missing_super.rb
Created May 22, 2011 11:57
Using method_missing properly by calling `super`
# This snippet is taken from:
# "The Polite Programmer's Guide to Ruby Etiquette"
# http://bit.ly/hrwdPY
class BlackMagicStereo < Stereo
def method_missing(name, *args)
if sym.to_s =~ /^play_(\w+)$/
system("open songs/#{$1}.m4a")
else
# Here, very important!