Write a record of the Ruby Blog system. It is also a bit of a record for me to learn Ruby.
First, I will introduce my learning environment.
System: ubuntu12.04
Documents: techotopia, Ruby documents, the hard way learn Ruby and other documents
Record: youdao cloud notes
Ruby
When I learn Ruby, I usually introduce the history and development of Ruby, but I think this is a bit of nonsense,
Ruby is written by a Japanese. It is an explanatory language.
Start
On Ubuntu, first determine whether it is installed Ruby.
If it is installed, the current number will be printed.
/**
123456 |
[Email protected]: ~ $ Ruby-V program 'Ruby 'is included in the following software packages: * ruby1.8 * ruby1.9.1 please try: sudo apt-Get install <selected software package> |
**/
Here, there are some differences between ruby1.8 and ruby1.9.1, and there are incompatibility issues.
Therefore, you must select the appropriate one.
Previously we mentioned that bianjiqiopenshift uses the Ruby on Rails development interface, using ruby1.9.3
Therefore, I am using a later version. You can choose one based on your needs.
For the differences between specific versions, You can Google it.
Install
1 |
sudo apt-get install ruby1.9.3 |
Then check whether the installation is successful:
12 |
ruby -vruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] |
We can see the ruby version number.
First Ruby command
Execute the first ruby command.
1 |
ruby -e ‘print "heloo ruby!\n"‘ |
-E is a parameter that enables Ruby to execute a line of Ruby statements on the command line of the terminal. You can also execute multiple lines of Ruby statements on one line of command line.
Refer:
The '-e' flag only allows a single line of code to be executed, but that does not mean that multiple '-e' flags cannot be placed on a single command line to execute multiple lines:
123 |
[email protected]:~$ ruby -e ‘print "hello ruby!\n"‘ -e ‘print "Hello Jeiao\n"‘hello ruby!Hello Jeiao |
Here, print can be replaced with puts or P. There are differences. I 've got more contact in the future. Let's talk about it, Mark.