Appointment Program In Ruby For a homework assignment for an online class (pretty much learning everything from the internet anyway) we were asked to build an appointment program. This is just a start, however I feel I am definitely over-complicating things and going about this the complete wrong way.
These were the instructions we were given:

Implement a superclass Appointment and sub classes OneTime, Day and Month. An appointment has a description (for example, &quot;Root Canal&quot;), and dates information (you can use Date object or Int Year, Int Month, Int Day). Fill an array of Appointment objects with a mixture of appointments.
Write a method OccursOn inside each of the sub classes that checks whether the appointment occurs on that date (OneTime), day (Day) or month (Month). Ask the user to enter a date to check (for example, 2006 10 5), and ask to user if they want to check against OneTime, Day or Month appointment. Based on what the user selected, OccursOn inside each of the sub class should run and display any matching appointment and associated descriptions.

require 'date'

class Appointment
    attr_accessor :info, :date, :year, :day, :month
    def initialize(info, date)
        @info = info
        @date = Date.parse(date)
    end
    
    def get_info
        @info
    end
    
    def get_date
        @date
    end
    
    def get_year
        @year = date.year
    end
    
    def get_month
        @month = date.mon
    end

end

class OneTime &lt; Appointment
    
    def OccursOn(year, month, day)
        puts &quot;The year you entered is #{year}&quot;
        puts &quot;The month you entered is #{month}&quot;
        puts &quot;The day you entered is #{day}&quot;
        appointments.each do |x|
            puts &quot;Month #{x.get_month}&quot;
            if x.get_month == month
                puts x.get_date
                puts x.get_info
            end
        end
    end
    
end

class Day &lt; Appointment
    
    def OccursOn(day)
        puts day
    end
    
end

class Month &lt; Appointment
    
    def OccursOn(month)
        puts month
    end
end

appointments = []
appointment1 = Appointment.new(&quot;Root Canal&quot;, &quot;31/10/2017&quot;)
appointment2 = Appointment.new(&quot;Cavity Filling&quot;, &quot;31/12/2017&quot;)
appointments &lt;&lt; appointment1 &lt;&lt; appointment2
puts appointment1.get_date
puts appointment2.get_date
puts appointment1.get_info

onetime1 = OneTime.new(&quot;Root Canal&quot;, &quot;31-10-2017&quot;)

puts &quot;Enter a date to check (for example, 31-10-2017)&quot;
checkdate = gets.chomp
checkdate = Date.parse(checkdate)

puts &quot;Would you like to check against OneTime, Day or Month appointment?&quot;
checkagainst = gets.chomp

if checkagainst == &quot;OneTime&quot; or checkagainst == &quot;onetime&quot;
    onetime1.OccursOn(checkdate.year, checkdate.month, checkdate.day)
elsif checkagainst == &quot;Day&quot; or checkagainst == &quot;day&quot;
    puts &quot;Day&quot; # run day check function 
elsif checkagainst == &quot;Month&quot; or checkagainst == &quot;Month&quot;
    puts &quot;Month&quot; # run month check function
else
    puts &quot;Invalid option.&quot;
end
I feel I am definitely overcomplicating things


I agree with you that the code is longer than necessary. Let's take a look.

YAGNI - you ain't gonna need it

Try to avoid writing code until a caller (such as a test method for a Story) forces you to write it. Then you know you really need it.

attr_accessor :info, :date, :year, :day, :month


The first two look good. I didn't notice any compelling reason to list y,m,d, as caller could get those from date. The day might be called mday for consistency with library.

def get_info
    @info
end

def get_date
    @date
end


Ummm, didn't attr_accessor already take care of those? We're writing in ruby, not java. Take advantage of its strengths!

I commented above that get_year &amp; get_month seem redundant. Also, it seems odd to list them without get_mday (or perhaps get_day). Better to elide them entirely.

    appointments.each do |x|


This seems to be a global reference. I can't imagine that's a good thing. Consider moving that list into a class, such as the Appointment class.

        if x.get_month == month


I suggest it would be more natural to phrase that as x.date.mon.

Your recurring Day &amp; Month classes appear to be unimplemented stubs, so far.
You have a design decision to make. Will adding a recurring appointment create several new entries until a date "very far" in the future? Or will it add a single entry and then you deal with that at query time? There is no right answer; each offers its own trade-offs.

puts "Would you like to check against OneTime, Day or Month appointment?"
checkagainst = gets.chomp


This seems a cumbersome UX. Rather than prompting, simply loop over all three, reporting the appointment and its type whenever you find a match.