|
Step 3 -- Run a simple ruby program |
|
Subject: Step 3 -- Run a simple ruby program
Author: Linux
In response to: Step 2 -- Install Ruby via RVM
Posted on: 09/06/2017 01:43:37 AM
Hello, World:
Inside file type: Press Ctrl-X and then Y to save the file Now you can run it: Output: Now make it more interactive:
puts "Hello, Wolrd"
puts ""
puts "Please enter your name."
name = gets.chop
puts "Hi, #{name}! I'm Ruby!"
Now you run it again: Output:
Hello, World!
Please enter your name.
Sam
Hi, Sam! I'm Ruby!
>
> On 09/06/2017 01:28:03 AM Linux wrote:
Now you can use the rvm command to install the latest version of Ruby:
rvm install ruby --default
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.4.0.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system.....
Installing required packages: gawk, libyaml-dev, sqlite3, autoconf, libgdbm-dev, libncurses5-dev,
automake, libtool, bison, libffi-dev, libreadline6-dev.......-
Requirements installation successful.
ruby-2.4.0 - #configure
ruby-2.4.0 - #download
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16.4M 100 16.4M 0 0 3801k 0 0:00:04 0:00:04 --:--:-- 3802k
ruby-2.4.0 - #validate archive
ruby-2.4.0 - #extract
ruby-2.4.0 - #validate binary
ruby-2.4.0 - #setup
ruby-2.4.0 - #gemset created /home/administrator/.rvm/gems/ruby-2.4.0@global
ruby-2.4.0 - #importing gemset /home/administrator/.rvm/gemsets/global.gems.....
ruby-2.4.0 - #generating global wrappers........
ruby-2.4.0 - #gemset created /home/administrator/.rvm/gems/ruby-2.4.0
ruby-2.4.0 - #importing gemsetfile /home/administrator/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.0 - #generating default wrappers........
This process will download and install Ruby and its components, and make this version of Ruby the default version your system will use. This will avoid conflicts if you have a version of Ruby already installed.
You can check the version:
ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
References:
|
|
|
|