IRB stands for “interactive ruby” and is a tool to interactively execute ruby expressions read from the standard input.
IRB stands for "interactive ruby" is a REPL (read–eval–print loop) for programming in the object-oriented scripting language Ruby. The abbreviation irb comes from the filename extension for Ruby is ".rb", although interactive Ruby files do not have an extension of ".irb". The program is launched from a command line and allows the execution of Ruby commands with immediate response, experimenting in real-time. It features command history, line editing capabilities, and job control.
Run in Linux
Run in Windows
Use of irb is easy, when executing irb, prompts are displayed as follows. Then, enter the ruby expression. An input is executed when it is syntactically complete.
prashanta@server:~$ irb
irb(main):001:0> 2+3
=> 5
Syntax:
irb.rb [options] [programfile] [arguments]
Command line options
Options Description -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 --prompt prompt-modeConfiguration:
IRB reads from ~/.irbrc when it’s invoked.
If ~/.irbrc doesn’t exist, irb will try to read in the following order:
The following are alternatives to the command line options. To use them type as follows in an irb session:
IRB.conf[:IRB_NAME]="irb" IRB.conf[:MATH_MODE]=false IRB.conf[:INSPECT_MODE]=nil IRB.conf[:IRB_RC] = nil IRB.conf[:BACK_TRACE_LIMIT]=16 IRB.conf[:USE_LOADER] = false IRB.conf[:USE_READLINE] = nil IRB.conf[:USE_TRACER] = false IRB.conf[:IGNORE_SIGINT] = true IRB.conf[:IGNORE_EOF] = false IRB.conf[:PROMPT_MODE] = :DEFALUT IRB.conf[:PROMPT] = {...} IRB.conf[:DEBUG_LEVEL]=0
Auto indentation:
To enable auto-indent mode in irb, add the following to your .irbrc :
IRB.conf[:AUTO_INDENT] = true
To enable autocompletion for irb, add the following to your .irbrc :
require 'irb/completion'
History
By default, irb disables history and will not store any commands you used.
IRB.conf[:SAVE_HISTORY] = 1000
This will now store the last 1000 commands in ~/.irb_history.
See IRB::Context#save_history= for more information.
Previous: Ruby Command Line Options
Next: Ruby Literals
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4