Skip to content

Instantly share code, notes, and snippets.

@mindplace
Created March 29, 2016 16:51
Show Gist options
  • Save mindplace/5ea54b21728f1eaf49b5c91204f330e4 to your computer and use it in GitHub Desktop.
Save mindplace/5ea54b21728f1eaf49b5c91204f330e4 to your computer and use it in GitHub Desktop.
class Student < LocalCohort
attr_reader :student_name, :email, :history, :local_cohort
def initialize(student_name, email, local_cohort)
@student_name, @email, @local_cohort = student_name, email, local_cohort
@history = []
end
def grade
events = history.select{|event| event[1].is_a?(Fixnum)}
return "No grades yet" if events.empty?
events.map{|set| set[1]}.inject(:+) / events.length
end
def add_history(event)
@history << event
end
def local_cohort_name
local_cohort.city
end
def global_cohort_name
local_cohort.global_cohort_name
end
def currently_in_phase
local_cohort.global_cohort.currently_in_phase
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment