Skip to content

Instantly share code, notes, and snippets.

@toche
Created June 18, 2012 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toche/2948332 to your computer and use it in GitHub Desktop.
Save toche/2948332 to your computer and use it in GitHub Desktop.
filename = ARGV.first
script = $0
puts "We're going to erase #{filename}"
puts "If you dont want that, hit CTRL-C (^C)"
puts "If you do want that, hit RETURN"
print "?"
STDIN.gets
puts "Opening the file.."
target ? file.open(filename, 'w')
puts "Truncating the file. See ya!"
target.truncate(target.size)
print "Line 1: "; line1 = STDIN.gets.chomp()
print "Line 2: "; line2 = STDIN.gets.chomp()
print "Line 3: "; line3 = STDIN.gets.chomp()
puts "I'm going to write these to a file"
target.write(line1)
target.write("\n")
target.write (line2)
target.write("\n")
target.write(line3)
target.write("\n")
puts "And finally we close it."
target.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment