Hello. I’m Ruby beginner, I’m not getting proper output, of course it’s
problem in my code not in Ruby itself.
Anyone can help to fix this?
The out put should be:
The Dark Knight Rises | Release Date: 2013 | Rating: 7.
But I’m also getting this “#Movie:0x102b26620” thing. Anyone can help
me why this is coming even after I used “to_s” ? your help will be
appreciated.
class Movie
def initialize(title, date, rating)
@title = title
@date = date
@rating = rating
end
def to_s
puts “Name: #{@title} | Release Date: #{@date} | Rating:
#{@rating}.”
end
def thumbs_up
@rating += @rating
end
def thumbs_down
@rating -= @rating
end
end
TheDarkKnight = Movie.new(“The Dark Knight Rises”, 2013, 7)