- echoinput.rb: echo standard input
to standard output (with line numbers); type
ruby echoinput.rb < echoinput.rb
at the command prompt (after installing Ruby) to display the program.
- sum.rb: compute sum of entered
numbers. Enter
ruby sum.rb
5
4
3
Control-Z
(where the last line is holding down the control key and pressing a Z)
to print a 12.
- generate.rb: generate a list of
numbers, one per line:
ruby generate.rb 20 30 3 | ruby sum.rb
98
- gpa.rb: compute GPA
- countvowels.rb: Ruby code to
count vowels in the input, illustrating breaking a program into multiple
functions with a main.
- phones.rb: simple phone book based on
arrays; to test, run irb and type
irb> load 'phones.rb'
irb> test_phone_book
- revised-phones.rb: revised
phone book using hash tables.