As of Ruby 2.4.0, you can start an interactive IRB session inside any Ruby script using these lines:
require 'irb' binding.irb
This will start an IBR REPL where you will have the expected value for
self and you will be able to access all local variables and instance variables that are in scope. Type Ctrl+D or
quit in order to resume your Ruby program.
This can be very useful for debugging.