I’m very new with ruby and I can’t understand one thing.
When I use this command from command prompt I can successfully save files.
irb
copy = "test"
File.open("output.html", 'w') {|f| f.write(copy) }
but when I save it to .rb file nothing happens. Script seems to be working, but it doesn’t save the file.
#!/usr/bin/env ruby
copy = "test"
File.open("output.html", 'w') {|f| f.write(copy) }
Why?
Use
Dir.pwdin irb to get your current working directory. This directory should hold your output.html file.