Setting up IRB and RI

Source: Internet
Author: User

setting up IRB and RI

Enter ruby-v to see if the Ruby version can be displayed

Now you can

ConfigurationIrbthe.

IRB is an interactive Ruby command-line tool that executes and gives results as soon as you enter a sentence .

The default IRB is not strong enough to configure it now .

IrbConfiguration

In the. IRBRC file ( file path :%USERPROFILE%\.IRBRC) that is placed in the personal directory .

Resource Manager > Address bar > input %userprofile%>shift+ Right-click > Open a command-line window

configuration file does not exist by default , you need to create a new one , enter it inside

# This is the IRB configuration file , and the IRB will read the configuration of this file before it runs .

# This file needs to be in the user directory

Require 'irb/completion' # turn on auto-completion

Irb.conf[:auto_indent]=true # turn on auto indent feature

* * Note : do not include Chinese notes.

Experience

Now you can open the ruby Interactive tool by entering IRB on the command line to experience the AutoComplete feature and auto indent .

For example :

input File.me, then press the tab key to automatically complete the function name Input and become File.method.

If you find more than one possibility , it won't be done automatically , but pressing TAB twice will show all possible names .

As for indentation, for example, enter def FUN1, then press enter, and the next line will indent two spaces for you to type in.

Next is Ri,ri is the tool for viewing help at the terminal , and if you prefer to use CHM, then the configuration will not need to be set up.

Ruby 's Help file is in Ruby\doc\ruby20.chm.

If you also want to try using the terminal to see the Help , then continue looking down .

First you need to installRiformat Help file

1. Run the Gem install rdoc-data installation at the terminal

2. then you need to generate ri data to run at the terminal

Rdoc-data-install

Gem RDoc--all--overwrite

3. you can now use RIS to query , such as the use of the Strip method to query String.

running at Terminal : Ri string#strip

It then outputs :

(from Ruby Core)

——————————————————————————

Str.strip-New_str

——————————————————————————

Returns a copy of STR with leading and trailing whitespace removed.

" hello". Strip #=> "Hello"

"\tgoodbye\r\n". Strip #=> "Goodbye"

Setting up IRB and RI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.