Ruby 简明教程
Ruby - Environment Setup
Local Environment Setup
如果您仍然希望为 Ruby 编程语言设置环境,那就让我们继续吧。本教程将教你有关环境设置的所有重要主题。我们建议你首先浏览以下主题,然后再进一步学习 −
If you are still willing to set up your environment for Ruby programming language, then let’s proceed. This tutorial will teach you all the important topics related to environment setup. We would recommend you to go through the following topics first and then proceed further −
-
Ruby Installation on Linux/Unix − If you are planning to have your development environment on Linux/Unix Machine, then go through this chapter.
-
Ruby Installation on Windows − If you are planning to have your development environment on Windows Machine, then go through this chapter.
-
Ruby Command Line Options − This chapter list out all the command line options, which you can use along with Ruby interpreter.
-
Ruby Environment Variables − This chapter has a list of all the important environment variables to be set to make Ruby Interpreter works.
Popular Ruby Editors
要编写 Ruby 程序,需要一个编辑器——
To write your Ruby programs, you will need an editor −
-
If you are working on Windows machine, then you can use any simple text editor like Notepad or Edit plus.
-
VIM (Vi IMproved) is a very simple text editor. This is available on almost all Unix machines and now Windows as well. Otherwise, your can use your favorite vi editor to write Ruby programs.
-
RubyWin is a Ruby Integrated Development Environment (IDE) for Windows.
-
Ruby Development Environment (RDE) is also a very good IDE for windows users.
Interactive Ruby (IRb)
交互式 Ruby (IRb) 针对实验提供一个 shell。在 IRb shell 中,您可以立即逐行查看表达式结果。
Interactive Ruby (IRb) provides a shell for experimentation. Within the IRb shell, you can immediately view expression results, line by line.
此工具随 Ruby 安装一同提供,因此您无需执行额外操作即可使用 IRb。
This tool comes along with Ruby installation so you have nothing to do extra to have IRb working.
只需在命令提示符下键入 irb ,就会启动一个交互式 Ruby 会话,如下所示:
Just type irb at your command prompt and an Interactive Ruby Session will start as given below −
$irb
irb 0.6.1(99/09/16)
irb(main):001:0> def hello
irb(main):002:1> out = "Hello World"
irb(main):003:1> puts out
irb(main):004:1> end
nil
irb(main):005:0> hello
Hello World
nil
irb(main):006:0>
不必担心我们在此处所做的事情。您将在后续章节中了解所有这些步骤。
Do not worry about what we did here. You will learn all these steps in subsequent chapters.