Try out the following commands!
Things that start with #
are comments - you don't need to type those out.
# navigate to your desktop
cd ~/Desktop #Linux, Mac
cd desktop #Windows
# make a directory called ruby_adventures
mkdir ruby_adventures
# navigate into the new ruby_adventures directory
cd ruby_adventures
# create a new file in the current (ruby_adventures) directory
touch setup.rb
# list the contents of the current (ruby_adventures) directory
ls
Not sure what a command does? Or how it works? Use man
Try using man
with a few commands. Type the letter q
to exit man
.
man ls
Output:
Working in the terminal, create a directory called gdi_ruby
in the location of your choosing.
Desktop? Documents? Somewhere you'll be able to find it again!
Inside the gdi_ruby
directory, create a file called setup.txt
.
Practice: Write a command line program that asks the user for the year they were born, then calculates their age in years, days, and seconds. Tell the user how old they are in these different formats. (Note: you'll be using gets
and puts
in this program, along with some math)
Temperature conversion! Make a program that asks the user for the temperature in Fahrenheit and print out the temperature in Celsius and Kelvins.
More info: Read more on methods and some basic methods already given to you Chapter 5 of Learn to Program