Last active
March 6, 2020 10:19
-
-
Save davidcelis/fe3c12aa08cf85e106f9 to your computer and use it in GitHub Desktop.
A simple metronome in Ruby
This file contains hidden or 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
class Metronome | |
def self.start(bpm: 120) | |
loop do | |
print "\a" | |
sleep (60 / bpm.to_f) | |
end | |
rescue Interrupt | |
puts "Exiting." | |
end | |
end | |
Metronome.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment