February 2 - Building an Interval Timer Method in Ruby
This coding exercise tests your ability to create an interval timer method in Ruby that runs a process at any interval passed to the method. Additionally, the method needs to be able to take a block.
Guide Tasks
- Read Tutorial
- Watch Guide Video
- Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license
Already a Bottega Student? Sign In
Summary
Build out an
interval
method that repeatedly runs a process.
Exercise Description
This coding exercise tests your ability to create an interval timer method in Ruby that runs a process at any interval passed to the method. Additionally, the method needs to be able to take a block.
Example Process
interval 2 do puts "hey there" end # waits 2 seconds then prints "hey there" # waits 2 seconds then prints "hey there" # waits 2 seconds then prints "hey there" # waits 2 seconds then prints "hey there" # ...
Real World Usage
You will practice two key coding practices with this exercise:
- Building methods that can yield to blocks, this is an important process when building complex methods.
- Utilizing Ruby's
sleep
method to manage the execution of a process.