How to Save an IRB Session

The Interactive Ruby Shell (IRB) is a command-line program that allows developers to type a Ruby program with immediate interpretation and execution of their commands. This allows the developer to experiment with the output of different functions in real time, step through output line by line to assist with debugging, and create session files that allow the application written in IRB to be invoked or edited later by the user or system script. You can edit your IRB initialization script to have it automatically record each session to a file.

Instructions

    • 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.

Related Searches:

References

Comments

You May Also Like

  • The IRB Policy

    Institutional review board (IRB) policy guides the approval or denial of research involving human subjects to ensure this research is ethical and...

  • What Is an IRB Application?

    An Institutional Review Board application is a procedure that scholars follow to ensure that their research is conducted with attention to ethical...

  • How to Create PDF Files With C Source Code

    Creating Adobe PDF (Portable Document Format) files with an application written in the C programming language could potentially involve many hours of...

  • How to Write an IRB Application

    The Institutional Review Board, or IRB, is a university committee made of faculty members or a hospital committee made of employees that...

  • IRB Management & Function

    Institutional Review Boards are committees at research institutions that monitor and approve studies that involve human participants. IRBs exist to protect human...

  • How to Capture Online Flash Files

    Flash media files are downloaded each time you visit a web page, but transferring that file to a convenient location on your...

  • How to Output a File in Ruby

    Ruby has a variety of ways which make it simple to output a file, depending on what you want to do with...

  • How to Learn Ruby

    Ruby is a programming language. Ruby borrows from several other programming languages, such as Java and Perl, and makes the coding easier....

  • How to Change a Class File

    The Java programming was developed and released by Sun Microsystems in 1995. Java programs are written as text files and then compiled...

Related Ads

Featured