Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/appointment.rb
@@ -0,0 +1,16 @@
class Appointment
attr_accessor :date, :doctor, :patient

@@all = []

def initialize(date, patient, doctor)
@date = date
@doctor = doctor
@patient = patient
@@all << self
end

def self.all
@@all
end
end
29 changes: 29 additions & 0 deletions lib/artist.rb
@@ -0,0 +1,29 @@
class Artist
attr_accessor :name, :genres, :songs
@@all = []

def initialize(name)
@name = name
@@all << self
end

def new_song(name, genre)
Song.new(name, self, genre)
end

def songs
Song.all.select do |song|
song.artist == self
end
end

def genres
self.songs.collect do |song|
song.genre
end
end

def self.all
@@all
end
end
29 changes: 29 additions & 0 deletions lib/doctor.rb
@@ -0,0 +1,29 @@
class Doctor
attr_accessor :name, :appointments, :patients
@@all = []

def initialize(name)
@name = name
@@all << self
end

def self.all
@@all
end

def new_appointment(patient, date)
Appointment.new(date, patient, self)
end

def appointments
Appointment.all.select do |appointment|
appointment.doctor == self
end
end

def patients
self.appointments.collect do |appointment|
appointment.patient
end
end
end
25 changes: 25 additions & 0 deletions lib/genre.rb
@@ -0,0 +1,25 @@
class Genre
attr_accessor :name, :artists, :songs
@@all = []

def initialize(name)
@name = name
@@all << self
end

def songs
Song.all.select do |song|
song.genre == self
end
end

def artists
self.songs.collect do |song|
song.artist
end
end

def self.all
@@all
end
end
29 changes: 29 additions & 0 deletions lib/patient.rb
@@ -0,0 +1,29 @@
class Patient
attr_accessor :name, :appointments, :doctors
@@all = []

def initialize(name)
@name = name
@@all << self
end

def self.all
@@all
end

def new_appointment(doctor, date)
Appointment.new(date, self, doctor)
end

def appointments
Appointment.all.select do |appointment|
appointment.patient == self
end
end

def doctors
self.appointments.collect do |appointment|
appointment.doctor
end
end
end
15 changes: 15 additions & 0 deletions lib/song.rb
@@ -0,0 +1,15 @@
class Song
attr_accessor :name, :artist, :genre
@@all = []

def initialize(name, artist, genre)
@name = name
@artist = artist
@genre = genre
@@all << self
end

def self.all
@@all
end
end
1 change: 0 additions & 1 deletion spec/01_artist_spec.rb
@@ -1,6 +1,5 @@
require "spec_helper"


describe "Artist" do

describe "#name" do
Expand Down