Created
April 3, 2009 17:23
-
-
Save prtksxna/89845 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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