From: Rick DeNatale Date: 2007-05-23T05:05:30+09:00 Subject: Re: Analysing ruby code On 5/22/07, cypher.dp@gmail.com wrote: > Hello everybody ! > > Somebody knows the best way or even a tool to split ruby code into its > different constructs ? > For example: > > class Foo > def initialize > @x = "y" > end > > def Bar(*args) > if args[0] > puts "Bar" + args[0] > else > puts @x > end > end > end > > should be split into an Array > > ["class Foo\n", "def initialize\n\t@x="y"\nend\n", "def Bar(*args)\n", > "if args[0]......... This looks like you are just splitting it into lines. If so then if it's in a file filename = 'myprog.rb' line_array = File.readlines(filename) Or if it's a string source = <