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
7
votes
3 answers

How can I input multibyte characters in rails console (or irb)?

guys. I am developing a Chinese application with rails. Now I want to input some Chinese characters in rails console but cannot do that, either in irb. Any guys who have the experience to solve this problem? I would appreciate your help!
Jimmy Huang
  • 4,252
  • 2
  • 22
  • 22
7
votes
4 answers

Ruby's irb equivalent in Perl?

I'm from Ruby background. Just wanted to know if there is anything like Ruby's irb in perl?
Abhishek
  • 79
  • 2
7
votes
1 answer

Why did I get "main.using is permitted only at toplevel" when I used a Refinement in IRB?

I tried to use a Refinement in IRB (v0.9.6, Ruby 2.3.0): module Foo refine Object do def foo() "foo" end end end using Foo # => RuntimeError: main.using is permitted only at toplevel This is basically the exact setup from the documentation…
user513951
  • 12,445
  • 7
  • 65
  • 82
7
votes
1 answer

How to force a vertical table or limit columns in Hirb?

I want to display few active records in rails console, I have Hirb enabled. The table is narrow enough to be displayed (so Hirb uses standard, horizontal table) but columns are so narrow that content is completely unreadable. Do you have any idea…
skalee
  • 12,331
  • 6
  • 55
  • 57
7
votes
2 answers

How can a Ruby script detect that it is running in irb?

I have a Ruby script that defines a class. I would like the script to execute the statement BoolParser.generate :file_base=>'bool_parser' only when the script is invoked as an executable, not when it is require'd from irb (or passed on the command…
ReWrite
  • 2,668
  • 1
  • 22
  • 14
7
votes
3 answers

How can I avoid the console output when assigning a value to a variable in Ruby

Is it possible to escape that effect when assigning to a value: irb(main):584:0>a = true =>true irb(main):584:0> I have a code that has lots of assignings and when I am trying to test it I can not see the result because of all these returned…
user2128702
  • 2,059
  • 2
  • 29
  • 74
7
votes
4 answers

Require not able to find ruby file

I am an absolute beginner in Ruby. I created a small ruby file, and it runs well when I run the command ruby "methods.rb". That means I am in the correct directory. But when I launch irb and run the command require "methods.rb", I get the following…
user2555452
  • 113
  • 5
7
votes
2 answers

"bundle install" not creating Gemfile.lock when issued from a Rails console system command

I have an odd use-case where I need to issue "bundle install" (as a system() command) from a Rails application on another freshly-made Rails application without a Gemfile.lock. I'm aware that this is usually done from the command line but I need to…
Erik Nomitch
  • 1,575
  • 13
  • 22
7
votes
4 answers

Ruby: overriding the puts method

I've got a small program meant to be run in IRB. It ultimately outputs something that looks like an array, though technically isn't an array. (The class inherits from array.) The problem is, when I do an instance of this class, e.g. example =…
Ben Downey
  • 2,575
  • 4
  • 37
  • 57
6
votes
3 answers

See where a symbol is defined in irb

I work on a pretty large rails project at work. Sometimes I need to hunt down class / constant definitions. Is there some built-in method in Ruby to do this for me? Example: irb> SOME_CONSTANT.__file__ => /some/path/to/a/file
Vlad the Impala
  • 15,572
  • 16
  • 81
  • 124
6
votes
1 answer

rails console with wirble?

How do i use rails console with the wirble gem? I originally had the code that wirble gives you and put it in my .irbrc At this point, irb worked fine with wirble (color highlighting), but when i would start rails console it would give an error…
Tallboy
  • 12,847
  • 13
  • 82
  • 173
6
votes
2 answers

Explanation of Ruby code for building Trie data structures

So I have this ruby code I grabbed from wikipedia and I modified a bit: @trie = Hash.new() def build(str) node = @trie str.each_char { |ch| cur = ch prev_node = node node = node[cur] if node == nil …
Benny Tjia
  • 4,853
  • 10
  • 39
  • 48
6
votes
2 answers

How do I quit from debugger without exiting my IRB session?

This is a long standing source of frustration, but maybe there is something I'm missing. If i'm in the middle of debugging, and I want to exit the debugger and return to IRB or Rails Console, "quit" won't work as it will exit IRB. "finish" also…
Jeremy Smith
  • 14,727
  • 19
  • 67
  • 114
6
votes
2 answers

Keyboard shortcuts to navigate the command line in irb

I've seen screencasts where users are running irb and as they write text they jump to the beginning/end of the line and beginning/end of words. What are the keystrokes used to do this? Does it depend on the shell that's being used?
Brand
  • 1,681
  • 1
  • 24
  • 32
6
votes
2 answers

Why Active Record relation is not returned in console?

I have finally started upgrading my Rails apps from 2.3.8 to 3.1.0. I was watching RailsCasts (http://railscasts.com/episodes/202-active-record-queries-in-rails-3) about Active Record queries. When I open up the console (rails c) and do query…
hade
  • 1,715
  • 1
  • 16
  • 24