有没有办法在运行脚本后获取交互式ruby shell?

时间:2012-03-29 18:31:09

标签: ruby

我希望能够使用我在脚本文件中创建的创建函数和对象,比如python -i 感谢

2 个答案:

答案 0 :(得分:3)

irb是ruby附带的交互式ruby shell。然后,您可以使用require 'file'在文件中加载方法,或者只需:irb -r module_name

答案 1 :(得分:3)

IRB是交互式shell,因此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

我不知道你为什么没有,但这里有所有的选择。