Determine if block contains sleep time
block_slept?
Given a block, runs it and returns whether or not the block contained sleeps or syncs
Introduced in v2.9
Examples
# Example 1 |
slept = block_slept? do
play 50
sleep 1
play 62
sleep 2
end
puts slept
|
#=> Returns true as there were sleeps in the block
|
# Example 2 |
in_thread do
sleep 1
cue :foo
end
slept = block_slept? do
sync :foo
play 62
end
puts slept
|
# trigger a cue on a different thread
# wait for the cue before playing the note
#=> Returns true as the block contained a sync.
|
# Example 3 |
slept = block_slept? do
play 50
play 62
end
puts slept
|
#=> Returns false as there were no sleeps in the block
|