if you define 2 classes with the same name, the methods of the first class can be used on the second. If both class definitions have methods with the same name, those of the second class will be used instead of those of the first class.

class Book
attr_reader :author, :title
def initialize(author, title)
@author = author
@title = title
end
def to_s
%("#{title}", by #{author})
end
end
class Book
def to_s
"I'm a book"
end
end
book = Book.new("Neil Stephenson", "Snow Crash")
puts %(The author of "#{book.title}" is #{book.author}.)
puts %(book = #{book}.) # => 'book = I'm a book'

--

--