I'm writing a Ruby class, and want to override the == method. I want to say something like:
class ReminderTimingInfo
attr_reader :times, :frequencies #don't want these to exist
def initialize(times, frequencies)
@times, @frequencies = times, frequencies
end
...
def ==(other)
@times == other.times and @frequencies == other.frequencies
end
end
How can I do this without making both times and frequencies publicly viewable?
FOLLOW UP:
class ReminderTimingInfo
def initialize(times, frequencies)
@date_times, @frequencies = times, frequencies
end
...
def ==(other)
@date_times == other.times and @frequencies == other.frequencies
end
protected
attr_reader :date_times, :frequencies
end