Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Extracting the Methods in a Ruby file

by thillai_selvan (Initiate)
on Jan 06, 2011 at 12:06 UTC ( [id://880799]=perlquestion: print w/replies, xml ) Need Help??

thillai_selvan has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Extracting the Methods in a Ruby file
by thundergnat (Deacon) on Jan 06, 2011 at 14:25 UTC

    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
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Extracting the Methods in a Ruby file
by Anonymous Monk on Jan 06, 2011 at 12:22 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://880799]
Approved by broomduster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found