user1036213
user1036213

Reputation: 23

Is there a way to get the interactive ruby shell after running a script?

I would like to be able to use the created functions and objects I create in the script file, like python -i Thanks

Upvotes: 1

Views: 2018

Answers (2)

Mike
Mike

Reputation: 364

IRB is the interactive shell so irb -r _path_to_file_

irb --help
Usage:  irb.rb [options] [programfile] [arguments]
  -f            Suppress read of ~/.irbrc
  -m            Bc mode (load mathn, fraction or matrix are available)
  -d                Set $DEBUG to true (same as `ruby -d')
  -r load-module    Same as `ruby -r'
  -I path           Specify $LOAD_PATH directory
  -U                Same as `ruby -U`
  -E enc            Same as `ruby -E`
  -w                Same as `ruby -w`
  -W[level=2]       Same as `ruby -W`
  --inspect     Use `inspect' for output (default except for bc mode)
  --noinspect       Don't use inspect for output
  --readline        Use Readline extension module
  --noreadline      Don't use Readline extension module
  --prompt prompt-mode
  --prompt-mode prompt-mode
            Switch prompt mode. Pre-defined prompt modes are
            `default', `simple', `xmp' and `inf-ruby'
  --inf-ruby-mode   Use prompt appropriate for inf-ruby-mode on emacs.
            Suppresses --readline.
  --simple-prompt   Simple prompt mode
  --noprompt        No prompt mode
  --tracer      Display trace for each execution of commands.
  --back-trace-limit n
            Display backtrace top n and tail n. The default
            value is 16.
  --irb_debug n     Set internal debug level to n (not for popular use)
  -v, --version     Print the version of irb

I dont know why yours didn't but here are all the options.

Upvotes: 3

Roland Mai
Roland Mai

Reputation: 31077

irb is the interactive ruby shell that comes with ruby. You can then use require 'file' to load the methods in a file, or you can do simply: irb -r module_name.

Upvotes: 3

Related Questions