How to make a command-line string code block argument become a real block of code inside a script

If a exec
Ruby myprog.rb '{ print " hi body "}'

How to convert that string to a real block to pass it to a method

def what_u_ask &b
  yield
End

what_u_ask ARGV[0]

This does not work for me. Thank you.

···

--
Posted via http://www.ruby-forum.com/.

This should work.

def what_u_ask &b
   yield
end

eval "what_u_ask #{ARGV[0]}"

Sam

···

On 07/02/12 08:22, gabe gabriellini wrote:

If a exec
Ruby myprog.rb '{ print " hi body "}'

How to convert that string to a real block to pass it to a method

def what_u_ask&b
   yield
End

what_u_ask ARGV[0]

This does not work for me. Thank you.

Solved !

Thanks Sam

eval "what_u_ask #{ARGV[0]}"

Works Great.

···

--
Posted via http://www.ruby-forum.com/.