Method: RubyCurses::TextView#saveas
- Defined in:
- lib/rbcurse/core/widgets/rtextview.rb
#saveas(name = nil, config = {}) ⇒ Object
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/rbcurse/core/widgets/rtextview.rb', line 692 def saveas name=nil, config={} unless name name = rb_gets "File to save as: " return if name.nil? || name == "" end exists = File.exists? name if exists # need to prompt return unless rb_confirm("Overwrite existing file? ") end l = getvalue File.open(name, "w"){ |f| l.each { |line| f.puts line } #l.each { |line| f.write line.gsub(/\r/,"\n") } } rb_puts "#{name} written." end |