irb

How Do You Clear The IRB Console?

偶尔善良 提交于 2019-12-02 13:59:56
How do you clear the IRB console screen? On Mac OS X or Linux you can use Ctrl + L to clear the IRB screen. Throw this inside %userprofile%\.irbrc and you're good def cls system('cls') end From IRB clear screen on windows . On *nix boxes `clear` on Windows system 'cls' # works `cls` # does not work on OSX system 'clear' # works `clear` # does not work TW Scannell On Ubuntu 11.10 system clear will mostly clear the irb window. You get a return => True value printed. A big mess of ugly text ruby-1.9.2-p290 :007 > system 'clear' what ya get: => true ruby-1.9.2-p290 :007 > user1323136 Command + K

how to get the current working directory's absolute path from irb

谁说我不能喝 提交于 2019-12-02 13:53:23
I'm running Ruby on Windows though I don't know if that should make a difference. All I want to do is get the current working directory's absolute path. Is this possible from irb? Apparently from a script it's possible using File.expand_path(__FILE__) But from irb I tried the following and got a "Permission denied" error: File.new(Dir.new(".").path).expand Dir.pwd seems to do the trick. http://ruby-doc.org/core/Dir.html#method-c-pwd Psylone File.expand_path File.dirname(__FILE__) will return the directory relative to the file this command is called from. But Dir.pwd returns the working

Is /etc/irbrc installed by OS X? Does irb read it?

主宰稳场 提交于 2019-12-01 18:02:53
While investigating an issue with irb on my Mac (OS X 10.11.5) I noticed /etc/irbrc . The first few lines follow: # Some default enhancements/settings for IRB, based on # http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks unless defined? ETC_IRBRC_LOADED # Require RubyGems by default. require 'rubygems' # Activate auto-completion. require 'irb/completion' # continued ... It seems to be out of date (rubygarden.org is gone, rubygems is in the standard library these days) and does things that I always thought I had to do in my own ~/.irbrc (set up completion, history, etc.). It is dated

Require not able to find ruby file

假装没事ソ 提交于 2019-12-01 17:36:17
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 response: LoadError: cannot load such file -- methods.rb from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:53:in `require' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:53:in `require' from (irb):1 from /usr/local/rvm/rubies/ruby-1.9.3

Require not able to find ruby file

故事扮演 提交于 2019-12-01 16:09:24
问题 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 response: LoadError: cannot load such file -- methods.rb from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:53:in `require' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1

Ruby: irb doesn't work on Windows

耗尽温柔 提交于 2019-12-01 09:39:50
I've installed Ruby 1.93 in my windows 7 PC using Ruby 1.9.3-p194 one click installer. I can use ruby command to interpret files, but when I type irb it gives me the following error: C:\Users\Acer>irb F:/Programs/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2111:in `expand_path': non-absolute home (ArgumentError) from F:/Programs/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2111:in `_rl_read_init_file' from F:/Programs/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2094:in `rl_read_init_file' from F:/Programs/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2515:in `readline_initialize

rails console with wirble?

梦想与她 提交于 2019-12-01 04:41:52
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 about wirble and halt. I changed the irbrc code so it doesnt halt but continues on error, this at least gets rails console load but theres no color highlighting. Any ideas what i should put? this is in my irbrc begin # load and initialize wirble require 'wirble' Wirble.init Wirble.colorize rescue puts "Couldn't load Wirble, continuing anyway" end Put

Require command not working within bash irb on Snow Leopard

♀尐吖头ヾ 提交于 2019-12-01 03:50:42
I am working on Zed Shaw's Learn Ruby the Hard Way Exercise 25 http://ruby.learncodethehardway.org/ex25.html When I navigate to the directory that holds the ruby file ex25.rb and launch IRB, I get these errors: Larson-2:~ larson$ cd Ruby Larson-2:Ruby larson$ ls ex25.rb Larson-2:Ruby larson$ irb ruby-1.9.2-p290 :001 > require 'ex25' LoadError: no such file to load -- ex25 from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in

Require command not working within bash irb on Snow Leopard

点点圈 提交于 2019-12-01 00:30:41
问题 I am working on Zed Shaw's Learn Ruby the Hard Way Exercise 25 http://ruby.learncodethehardway.org/ex25.html When I navigate to the directory that holds the ruby file ex25.rb and launch IRB, I get these errors: Larson-2:~ larson$ cd Ruby Larson-2:Ruby larson$ ls ex25.rb Larson-2:Ruby larson$ irb ruby-1.9.2-p290 :001 > require 'ex25' LoadError: no such file to load -- ex25 from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from

How to create a custom method for the rails console?

六月ゝ 毕业季﹏ 提交于 2019-11-30 23:44:51
When I'm using the Rails console in Ubuntu for a long session I define the clear method: def clear; system 'clear' end So when my console is getting dirty the only thing I have to do is type clear and the console gets cleared. I would like to use this function without to re-type it every time. Thanks in advance. Just put it in the ~/.irbrc file. It gets loaded every time you run irb or rails console . The Rails console is just irb with your Rails application environment loaded. Find more infos about irb here: http://ruby-doc.com/docs/ProgrammingRuby/html/irb.html#S2 Put this function to ~/