开发者

Good Ruby shell?

For Python I use PyCrust, which is a nice graphical shell that feels like a good Jav开发者_Python百科a IDE (has autocompletion, inline documentation and can save history).

Is there anything similar for Ruby?


If you don't need it to be graphical, you can use irb, wich I think is a part of the ruby package. It has autocompletion. To enable it say:

require 'irb/completion'

It can also save your history between sessions.
You should write your own .irbrc file to configure it.
I don't know all the features it has, but I guess there are more than the ones I have mentioned here.


Some up and coming ruby shells:

  • ir - a slim ruby shell
  • irb2 - rewrite of irb

Thorough documentation of irb:

  • irb commands
  • configuring irb

Some gems I've written that'll enhance your ruby shell experience:

  • hirb - console view framework
  • bond - enhanced autocompletion i.e. completing method arguments
  • boson - console command manager and more


The gem "looksee" is helpful for method lookup.

Watch a video at RubyPulse.

You can see all the methods available at the given variable as below.

>> s = "Hello World"
=> "Hello World"
>> lp s
=> String
  %            casecmp   downcase!  include?          next        size         sum        tr_s   
  *            center    dump       index             next!       slice        swapcase   tr_s!  
  +            chars     each       insert            oct         slice!       swapcase!  unpack 
  <<           chomp     each_byte  inspect           partition   split        taguri     upcase 
  <=>          chomp!    each_char  intern            replace     squeeze      taguri=    upcase!
  ==           chop      each_line  is_binary_data?   reverse     squeeze!     to_f       upto   
  =~           chop!     empty?     is_complex_yaml?  reverse!    start_with?  to_i     
  []           concat    end_with?  length            rindex      strip        to_s     
  []=          count     eql?       lines             rjust       strip!       to_str   
  bytes        crypt     gsub       ljust             rpartition  sub          to_sym   
  bytesize     delete    gsub!      lstrip            rstrip      sub!         to_yaml  
  capitalize   delete!   hash       lstrip!           rstrip!     succ         tr       
  capitalize!  downcase  hex        match             scan        succ!        tr!      
Enumerable
  all?     drop             enum_cons        first     max      minmax_by  reverse_each  to_a
  any?     drop_while       enum_slice       grep      max_by   none?      select        zip 
  collect  each_cons        enum_with_index  group_by  member?  one?       sort        
  count    each_slice       find             include?  min      partition  sort_by     
  cycle    each_with_index  find_all         inject    min_by   reduce     take        
  detect   entries          find_index       map       minmax   reject     take_while  
Comparable
  <  <=  ==  >  >=  between?
Object
  dump_lookup_path  lookup_path     taguri   to_yaml             to_yaml_style
  local_methods     recent_hisotry  taguri=  to_yaml_properties
PP::ObjectMixin
  pretty_print  pretty_print_cycle  pretty_print_inspect  pretty_print_instance_variables
Kernel
  ==        dup       id                          instance_variables  private_methods    tap    
  ===       enum_for  inspect                     is_a?               protected_methods  to_a   
  =~        eql?      instance_eval               kind_of?            public_methods     to_enum
  __id__    equal?    instance_exec               method              respond_to?        to_s   
  __send__  extend    instance_of?                methods             send               type   
  class     freeze    instance_variable_defined?  nil?                singleton_methods  untaint
  clone     frozen?   instance_variable_get       object_id           taint            
  display   hash      instance_variable_set       pretty_inspect      tainted?         
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜