From: Gordon Thiesfeld Date: 2008-03-26T07:24:55+09:00 Subject: Re: golf: tabs to bullets On Tue, Mar 25, 2008 at 5:11 PM, Gordon Thiesfeld wrote: > Similar to Joel's approach... > > #bullets.rb > h={} > %w(\ * - o x).each_with_index{|b, i| h["\t" * i]= " " * i + "#{b} " } > puts gets.gsub(/^(\t*)/){ h[$1]} until $stdin.eof? > > C:\ruby\scripts\>cat input_file | ruby bullets.rb > > > foo > * bar > - baz > o hello > - world > Except it was broken. I'll try it again. #bullets.rb h={''=>''} %w(* - o x).each_with_index{|b, i| h["\t" * (i+1)]= "#{' ' * i}#{b} " } puts gets.gsub(/^(\t*)/){ h[$1] } until $stdin.eof?