lib/utility_belt/print_methods.rb
# allows you to create a class interactively bit by bit 
# and then edit the whole thing within an editor
allows you to create a class interactively bit by bit
and then edit the whole thing within an editor
allows you to create a class interactively bit by bit and then edit the whole thing within an editor
def edit_class(editor, obj)
      require 'ruby2ruby'
      unless @file
        @file = Tempfile.new("irb_tempfile")
        File.open(@file.path, 'w+') do |f|
          f.write Ruby2Ruby.translate(obj)
        end
      end
      system("#{editor} #{@file.path}")
      Object.class_eval(File.read(@file.path).gsub("\r", "\n"))
    rescue Exception => error
      puts @file.path
      puts error
    end
def edit_class ( editor , obj ) require 'ruby2ruby' unless @file @file = Tempfile . new ( "irb_tempfile" ) File . open ( @file . path , 'w+' ) do | f | f . write Ruby2Ruby . translate ( obj ) end end system ( "#{editor} #{@file.path}" ) Object . class_eval ( File . read ( @file . path ) . gsub ( "\r" , "\n" ) ) rescue Exception => error puts @file . path puts error end
allows you to create a class interactively bit by bit
and then edit the whole thing within an editor
allows you to create a class interactively bit by bit and then edit the whole thing within an editor
editor
<not_specific>
obj
<not_specific>