Module: Jekyll::TimeInProgram
- Defined in:
- jekyll/_plugins/time_in_program.rb
Instance Method Summary collapse
- #program_year(student) ⇒ Object
- #students_in_program_year_ge(studentlist, year) ⇒ Object
-
#years_in_program(student) ⇒ Object
given a gradawan student object, return their time in program as a float to .01 years.
Instance Method Details
#program_year(student) ⇒ Object
40 41 42 43 44 45 46 |
# File 'jekyll/_plugins/time_in_program.rb', line 40 def program_year(student) # program year is years since admission rounded up to next highest integer, # e.g. student who has been here for 1.5 years is in program year 2 return (years_in_program(student)).ceil; end |
#students_in_program_year_ge(studentlist, year) ⇒ Object
48 49 50 51 52 53 54 |
# File 'jekyll/_plugins/time_in_program.rb', line 48 def students_in_program_year_ge(studentlist, year) # given a list of students, return those who have been in the program # for "year" number of years or greater return studentlist unless studentlist.is_a?(Enumerable) studentlist = studentlist.values if studentlist.is_a?(Hash) studentlist.select { |student| program_year(student) >= year } end |
#years_in_program(student) ⇒ Object
given a gradawan student object, return their time in program as a float to .01 years
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'jekyll/_plugins/time_in_program.rb', line 13 def years_in_program(student) values = student['admit_term'].split("/") year = values[0].to_i month = values[1].to_i if month == 1 day = 3 elsif month == 6 month = 5 day = 15 elsif month == 9 month = 8 day = 20 end time_entered = DateTime.new(year,month,day) ; # get todays's date in year as real number # e.g. July 1, 2015 = 2015.5 # seconds in 1 non-leap year = 365 days = 365×24×3600 = 31536000 # seconds in average year = 365.25 days = 365.25×24×3600 = 31557600 # (not taking into account non-leap year every 400 years) # then we round to nearest 0.01 years return (( DateTime.now - time_entered) / 365.25).round(2); end |