Skip to content

Instantly share code, notes, and snippets.

@prtksxna
Created April 3, 2009 17:23
Show Gist options
  • Save prtksxna/89845 to your computer and use it in GitHub Desktop.
Save prtksxna/89845 to your computer and use it in GitHub Desktop.
def how_many_tabs(tabkeeper)
tabs = ""
tabkeeper.times do |t|
tabs += "\t"
end
return tabs
end
path = gets.chomp
unfile = ""
file = File.new(path,"r")
tabkeeper = 0
file.each_byte do |ch|
if ch == 59
unfile += ch.chr
unfile += "\n"
unfile += how_many_tabs tabkeeper
elsif ch == 123
tabkeeper += 1
unfile += ch.chr
unfile += "\n"
elsif ch == 125
tabkeeper -= 1
unfile += "\n"
unfile += how_many_tabs tabkeeper
unfile += ch.chr
else
unfile += ch.chr
end
end
file.close
puts "Where to put?"
where = gets.chomp
file = File.new(where,"w")
file.syswrite(unfile)
file.close
puts unfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment