Questions tagged [irb]

Interactive Ruby (IRB) is a shell for programming in Ruby. The program can be launched from a command prompt and allows the execution of Ruby commands line by line.

Interactive Ruby Shell (IRB) is a shell for programming in Ruby. The program can be launched from a command prompt and allows the execution of Ruby commands line by line. It features command history, line editing capabilities, and job control, and is able to communicate directly as a shell script over the Internet and interact with a live server. It was developed by Keiju Ishitsuka.

772 questions
5
votes
4 answers

Rails console history command (via pry) -- can it be grepped or tailed?

In Rails 4 rails console I can type history and it will behave just like the history command from the bash shell. E.g.: [25] my_rails_project » history 1: Nomination 2: {:ad => "asdfsdasadf"} 3: Nomination.count 4: Nomination.count.to_sql …
Purplejacket
  • 1,808
  • 2
  • 25
  • 43
5
votes
1 answer

Test local version of gem in Rails project

My Rails site uses a certain gem which is really not very good. Every time I need to do something new I end up having to spend as much time adding features to the gem as I do adding code to the actual Rails project. But I don't mind, and I have my…
tsm
  • 3,598
  • 2
  • 21
  • 35
5
votes
1 answer

last result in Ruby REPL

In the Scala REPL if you evaluate something its value is stored in res{N}, as is discussed here: How can I access the last result in Scala REPL?. Is there a similar feature for the ruby REPL, or do the results get lost if you don't capture their…
Max DeLiso
  • 1,213
  • 11
  • 23
5
votes
2 answers

Ruby Configure IRB to Pretty_Inspect by Default

I'm fairly new to ruby, and am configuring IRB. I like pretty print (require 'pp'), but it seems a hassle to always type pp for it to pretty print it. What I'd like to do is make it pretty print by default, so if i have a var , say, 'myvar', and…
user151975
  • 151
  • 1
  • 7
5
votes
1 answer

What's the point of an interactive Ruby subshell?

Starting up an interactive Ruby shell in the Terminal ('irb'), one can continue to open up irb subshells endlessly. What's the point of this?
po.studio
  • 4,007
  • 5
  • 25
  • 37
5
votes
1 answer

Can not use variable in IRB after var = Watir::Browser.start 'url'

1.9.3-p327 :001 > require 'watir-webdriver' => true 1.9.3-p327 :002 > b = Watir::Browser.new Then firefox starts and I can do nothing. My IRB does not allow me to enter new commands. Tried different variations of browser initialization: b =…
Ivan Danci
  • 512
  • 5
  • 24
5
votes
1 answer

Why Module.methods() and respond_to? works differently in irb than in script?

I'm trying to use reflective methods in Ruby, and running into a behavior that I find really surpising. The following examples seems to work differently in IRB and when called a ruby script: Example 1: def myfun; end p respond_to?(:myfun) In IRb,…
inger
  • 19,574
  • 9
  • 49
  • 54
5
votes
1 answer

How to escape/exit in IRB after entering code that requires more input/does not execute right away

A particular line of code results in no output, and IRB exits out of the >> prompt. I am not looking to exit IRB, but just to exit to a state preceding the line of code that caused the >> prompt to go away. >> stop_words = %w {the a and if} >>…
Bodhidarma
  • 519
  • 1
  • 7
  • 25
5
votes
3 answers

What is the class of "if/unless" etc

Considering that everything in Ruby is an object and we can open irb and type things like 4.class and "Text".class to see from which class an object is, why do if.class and unless.class give no return value?
user1894919
  • 148
  • 7
5
votes
3 answers

How to get unstuck in Ruby irb?

Possible Duplicate: Is there a way to get out of a “hung” state in IRB? I am using IRB. When I am coding I noticed that I get "stuck" when the line ends with "/": irb(main):057:0/ When that happens I cannot do anything, I can't exit, define…
user1804592
  • 137
  • 3
  • 11
5
votes
1 answer

Rails: How to cancel current statements in rails console?

I'm using Rails 2.3.8 with jRuby for a project. and I regularly use rails console for testing my classes and API, where somehow I experience one problem. when I am working in the Rails console, if I mistakenly input some multi-line commands, is…
Sarun Sermsuwan
  • 3,608
  • 5
  • 34
  • 46
5
votes
3 answers

running a Unit test from irb or pry

Is there a way to run a testfile from inside an irb or pry session? I tried load './testfile.rb, but that doesn't run the tests in the testfile. My Testfile looks like this: require 'test/unit' require './sudoku.rb' class SudokuTest <…
FlyingFoX
  • 3,379
  • 3
  • 32
  • 49
4
votes
1 answer

How to customize the return output of Ruby commands in Pry

I was able to customize the prompt for Pry with the Pry.config.prompt setting in ~/.pryrc in order to make Pry simpler for kids. Now I want to get rid of the return output: Enter Ruby code> puts 'hello' hello => nil Enter Ruby code> The => nil is…
at.
  • 50,922
  • 104
  • 292
  • 461
4
votes
3 answers

Rails console limits text output. How do I get to see it all?

It seems like the Rails console limits its character output to about 880 characters. How do I remove this limitation? Printing large objects, or text fields from the database, gives output like this: => #
Magne
  • 16,401
  • 10
  • 68
  • 88
4
votes
1 answer

Why don't all the readline shortcuts work in psql (or IRB, or the Rails console)?

In bash and zsh, you can use handy readline shortcuts like these to navigate between words, delete from the middle of the line, etc. However, only a couple of these (Ctrl-A and Ctrl-E and a couple of others) work in psql, IRB, and the Rails console…
yalestar
  • 9,334
  • 6
  • 39
  • 52