Created
March 25, 2012 07:59
-
-
Save iamsolarpowered/2192283 to your computer and use it in GitHub Desktop.
12-Bar Blues in Ruby
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 Play | |
def self.note note = nil | |
@note = note.to_s.upcase | |
self | |
end | |
def self.for bars = 1, length = 1 | |
bars.times do | |
puts @note | |
sleep length | |
end | |
end | |
end | |
class Integer | |
def bar note | |
Play.note(note).for(self) | |
end | |
alias :bars :bar | |
end | |
# Just in E for now | |
12.times do | |
4.bars :e | |
2.bars :a | |
2.bars :e | |
1.bar :b | |
1.bar :a | |
1.bar :e | |
1.bar :b | |
end | |
puts 'Goodnight!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment