N
neleai
Hi,
I am trying to write program that allows you add arbitrary default
value for functions ie:
def blit(source,target,x,y,wi=source.width,he=source.heigth)
I use folowing script which adds foo=expr if !foo to source but it is
bit dirty solution.
Is there any way how incorporate this in ruby?
modif=""
IO.read(ARGV[0]).each{|line|
if line=~ /(def[^(]*)\((.*)\)/
line+=$1+'('
ad=""
$2.split(?.each{|w| #if I use colon I must use ruby
parser for spliting
if w=~ /(.*)=(.*)/ #
line+=$1+?,
ad+="#{w} if !#{$1}\n"
else
modif+=w
end
modif.chop!+=ad
}
else
modif+=line
end
}
puts modif
I am trying to write program that allows you add arbitrary default
value for functions ie:
def blit(source,target,x,y,wi=source.width,he=source.heigth)
I use folowing script which adds foo=expr if !foo to source but it is
bit dirty solution.
Is there any way how incorporate this in ruby?
modif=""
IO.read(ARGV[0]).each{|line|
if line=~ /(def[^(]*)\((.*)\)/
line+=$1+'('
ad=""
$2.split(?.each{|w| #if I use colon I must use ruby
parser for spliting
if w=~ /(.*)=(.*)/ #
line+=$1+?,
ad+="#{w} if !#{$1}\n"
else
modif+=w
end
modif.chop!+=ad
}
else
modif+=line
end
}
puts modif