Skip to content

Instantly share code, notes, and snippets.

@davidcelis
Last active March 6, 2020 10:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcelis/fe3c12aa08cf85e106f9 to your computer and use it in GitHub Desktop.
Save davidcelis/fe3c12aa08cf85e106f9 to your computer and use it in GitHub Desktop.
A simple metronome in Ruby
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