To Lecture Notes

IT 231 -- 9/27/12

 

Review Questions

  1. How do you change the port number to 3726 for the WEBrick server?
  2. What is the range of numbers for well-known ports?
    Ans: 1 to 1023.
     
  3. What does \n mean in Ruby?
    Ans: It is the new line character.
     
  4. Find the mistakes in this line of an .html.erb file:
  5. Ans: Here are two possible corrected versions:
  6. What do these Ruby statements do?
  7. Write a Ruby script that prints "Hello, world."
  8. Write a Ruby statement that assigns 256 to the grand total.
  9. Write controller code with a view that converts 5 inches to centimeters and displays the answer. (1 inch = 2.54 cm). Ans:
  10. List six ways of running Ruby code. Ans:
    1. Interactive Ruby (IRB)
    2. Ruby Script
    3. Embedded Ruby (ERB) in a view
    4. In the Rails controller
    5. From the Rails Console
    6. Load from the Rails Console
    7. From a Rails seed file.

  11. Which of these are legal Ruby variable names?.
  12. Try out these Ruby statements in IRB. What do you think is happening?
    Ans: This is an example of variable interpolation. #{a} means insert the value of the variable a at this location in the string.  
  13. Change the double quotes in Question 11 to single quotes. Explain.
    Ans: Variable interpolation and escape characters only work with double quotes, not single quotes.

 

Ruby Details

 

Classes and Objects

 

UML Diagrams

 

Project 3

 

Control Structures

 

Some ActiveRecord Method Calls