Created
April 28, 2012 22:07
-
-
Save wrburgess/2522380 to your computer and use it in GitHub Desktop.
Ruby Class Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Movie | |
| attr_reader :title, :rank | |
| attr_writer :title, :rank | |
| # or attr_accessor :title, :rank | |
| def initialize(title, rank = 0) | |
| @title = title | |
| @rank = rank | |
| end | |
| def to_s | |
| "The movie name is #{@title} and its rank is #{@rank}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment