block_given?

block_given?

ri

 ---------------------------------------------------- Kernel#block_given?
      block_given?   => true or false
      iterator?      => true or false
 ------------------------------------------------------------------------
      Returns  true  if  yield  would execute a block in the current
      context. The  iterator?  form is mildly deprecated.
 
         def try
           if block_given?
             yield
           else
             "no block"
           end
         end
         try                  #=> "no block"
         try { "hello" }      #=> "hello"
         try do "hello" end   #=> "hello"
 

refe

 Kernel#block_given?
 --- iterator?
 --- block_given?
 
     メソッドにブロックが与えられている時には真、そうでない時に偽
     を返します。