block_given?
A method of the Kernel module, and thus available everywhere in Ruby, block_given?
allows you to check whether a block was passed as an argument to a function.
Here’s a less contrived example, which came out of my solution to a problem on RubyMonk:
Without a block argument, the method simply adds array elements to a specified initial value. When a block is passed, each array element is first yielded to the block (which squares the element in the example) and then summed.