Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Created April 28, 2012 22:07
Show Gist options
  • Select an option

  • Save wrburgess/2522380 to your computer and use it in GitHub Desktop.

Select an option

Save wrburgess/2522380 to your computer and use it in GitHub Desktop.
Ruby Class Example
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