I am accessing a file, and before I append to it, I want to delete the last line from the file. Is there any efficient way of doing this in Ruby?
This is what I am using to access the file:
file = File.new("imcs2.xml", "a")
I'm not gonna try to guess what you're trying to do, but if you're trying to get rid of the closing tag of the root element in an XML file so that you can add more child tags, then re-add the closing root tag, I would imagine that there are ruby modules out there that facilitate this task of writing/editing XML. Just sayin.
Perhaps Builder:
hpricot also seems to work:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With