From: Mark Hubbart Date: 2005-02-12T08:45:54+09:00 Subject: Re: Correction to one of my input lines Hi, On Sat, 12 Feb 2005 03:46:28 +0900, Harry Truax wrote: > Hi, > > I noticed an error in one of my input lines - > > Here is another: > > box1_32 = $CUR % (condition(((box1_31).count).eq(0.to_s), '', > condition((box1_31).gt(0.to_s), (box1_31) * ((7.9.to_s).percent), nil))) > print 'box1_32', box1_32 > > Convert the above to: > > box1_32 = $CUR % (box1_31.to_f > 0.0 ? box1_31.to_f * 0.079 : 0.0) print > 'box1_32', box1_32 > > THE INPUT LINE SHOULD BE: > > box1_32 = $CUR % (condition(((box1_31).count).eq(0.to_s), '', > condition((box1_31).gt(0.to_s), (box1_31) * ((7.9.to_s).percent), nil))) > > THE OUTPUT SHOULD BE: > > box1_32 = $CUR % (box1_31.to_f > 0.0 ? box1_31.to_f * 0.079 : 0.0) Perhaps it would be easier to modify Ruby to accept the original syntax, than to modify the syntax to fit Ruby. For the above example: def condition(cond, iftrue, iffalse) cond ? iftrue: iffalse end class Object alias_method :eq, :== end ... and so on. Adding the proper methods should make it possible to run your original code directly within Ruby. If you don't want to pollute the namespace of your enclosing script, you might try something like this (UNTESTED!) funky_script_text = load_funky_script_file ruby_conversion_code = <