Created
September 2, 2011 03:26
-
-
Save jeremywrowe/1187859 to your computer and use it in GitHub Desktop.
arduino remote outlet button meta programming awesomeness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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