Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Created September 2, 2011 03:26
Show Gist options
  • Save jeremywrowe/1187859 to your computer and use it in GitHub Desktop.
Save jeremywrowe/1187859 to your computer and use it in GitHub Desktop.
arduino remote outlet button meta programming awesomeness
module Commands
class << self
%w{one one two two three three}.each_with_index do |button, index|
current = 4 + index
method_prefix = (current % 2 == 0 ? "off" : "on")
define_method "outlet_#{button}_#{method_prefix}" do |tty|
current
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment