How to Save an IRB Session

104 186
    • 1). Open the "Start" menu and type "%AppData%" in the search bar. Press "Enter."

    • 2). Double-click "Ruby" and then double-click ".irbrc."

    • 3). Open the file in Notepad by selecting it from the default applications list that appears on the screen.

    • 4). Add the following lines of code to the end of the file:

      module IRB

      def IRB.buffer; @log; end

      @log = ""

      class WorkSpace

      alias backup_evaluate evaluate

      def evaluate(context, statements, file = __FILE__, line = __LINE__)

      result = backup_evaluate(context, statements, file, line)

      if /IRB\.buffer/.match(statements)

      IRB.buffer << "#{statements.chomp}\n"

      else

      IRB.buffer << "#{statements.chomp} #=> #{result.inspect}\n"

      end

      result

      end

      end

      end

    • 5). Save the file by clicking "File," then "Save." When you begin a new IRB session, the file will be automatically saved in a file called "IRB.buffer" in the directory you launched your Ruby application from.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.