in reply to Extracting the Methods in a Ruby file
Looks like a flip-flop operator might work, for simple cases at least.
while (<DATA>){ print if ( /def/ .. /end/ ); } __DATA__ puts "hai" def mult(a,b) a * b end puts "hello" def getCostAndMpg cost = 30000 # some fancy db calls go here mpg = 30 return cost,mpg end AltimaCost, AltimaMpg = getCostAndMpg puts "AltimaCost = #{AltimaCost}, AltimaMpg = {AltimaMpg}"
yields:
def mult(a,b) a * b end def getCostAndMpg cost = 30000 # some fancy db calls go here mpg = 30 return cost,mpg end
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |