Ruby
Created by Yukihiro Matsumoto in 1995. Part scripting language, part object-oriented, part functional, Ruby is a modern language with something to offer to everyone. It is in interpreted language (interpreter written in C) and has a significant standard library.
Useful Links
- The Ruby homepage contains just about everything you would need, including many links to useful documentation and tutorials.
- Wikipedia page
- 99 bottles of beer program (from here):
def bottles(beer, wall = false) "#{beer>0 ? beer : "no more"} bottle#{"s" if beer!=1} of beer#{" on the wall" if wall}" end 99.downto(0) do |remaining| puts "#{bottles(remaining,true).capitalize}, #{bottles(remaining)}." if remaining==0 print "Go to the store and buy some more" remaining=100 else print "Take one down, pass it around" end puts ", #{bottles(remaining-1,true)}.\n\n" end
Tools
We will use the standard Ruby interpreter (written in C) version 2.7.
Everything you need is already installed on CS department lab machines.
To install on your virtual machine, follow these steps:
-
Run
sudo apt install -y ruby
- That's it!
How I will run your code
The programs you submit should be in a single file
called proj.rb
, for either part of the project.
I will test your code by running the following commands
using the software available in the lab environment or using the instructions
above:
ruby proj.rb
Phase 1 Requirements
For this language, you need to implement modifications B, C, D, F, G, H, I, and J. See the Phase 1 page for details on what this means.
Phase 2
See the Phase 2 Page for the list of suggested
problems. Of the ones listed, I recommend the following as being most
well-suited for ruby:
- Matrix Calculator
- Image Creator
- Game Scheduler
- TODO list
- Game with hidden agenda
- Guess the language
- Find the missing digits
- Sports Ticker
- Rock, Paper, Scissors
- Music Maker
- ??? (you choose!)