Skip to Content
Ruby in a Nutshell
book

Ruby in a Nutshell

by Yukihiro Matsumoto
November 2001
Intermediate to advanced
218 pages
6h 22m
English
O'Reilly Media, Inc.
Content preview from Ruby in a Nutshell

irb

irb (Interactive Ruby) was developed by Keiju Ishitsuka. It allows you to enter commands at the prompt and have the interpreter respond as if you were executing a program. irb is useful to experiment with or to explore Ruby.

irb [ options ] [ programfile ] [ argument... ]

Here are the irb options:

-f

Suppresses loading of ~/.irbrc.

-m

Math mode. Performs calculations using rational numbers.

-d

Debugger mode. Sets $DEBUG to true.

-r lib

Uses require to load the library lib before executing the program.

-v
--version

Displays the version of irb.

--inspect

Inspect mode (default).

--noinspect

Noninspect mode (default for math mode).

--readline

Uses the readline library.

--noreadline

Suppresses use of the readline library.

--prompt mode
--prompt-mode mode

Sets the prompt mode. Predefined prompt modes are default, simple, xmp, and inf-ruby.

--inf-ruby-mode

Sets the prompt mode to inf-ruby and suppresses use of the readline library.

--simple-prompt

Sets the prompt mode to simple mode.

--noprompt

Suppresses the prompt display.

--tracer

Displays a trace of method calls.

--back-trace-limit n

Sets the depth of backtrace information to be displayed (default is 16).

Here is a sample irb interaction:

irb irb(main):001:0> a = 25 25 irb(main):002:0> a = 2 2 irb(main):003:0> matz@ev[sample] irb irb(main):001:0> a = 3 3 irb(main):002:0> a.times do |i| irb(main):003:1* puts i irb(main):004:1> end 0 1 2 3 irb(main):005:0> class Foo<Object irb(main):006:1> def foo irb(main):007:2> puts "foo" irb(main):008:2> end irb(main):009:1> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Ruby Wizardry

Ruby Wizardry

Eric Weinstein
Ruby by Example

Ruby by Example

Kevin C. Baird
Ruby Best Practices

Ruby Best Practices

Gregory T Brown

Publisher Resources

ISBN: 0596002149Errata Page