class Period
Attributes
course_title[R]
The title of the course or event of the period. @return [String] the title
end_time[R]
The time (only) of day that the period ends at. ex. '10:30 AM' or '02:40 PM' @return [String] the time
location[R]
The location of the period without any preceding text. e.g. '312' not 'Room 312' @return [String] the location
start_time[R]
The time (only) of day that the period starts at. ex. '10:30 AM' or '02:40 PM' @return [String] the time
Public Class Methods
new(course, start_time, end_time, location)
click to toggle source
# File lib/rhs-schedule/period.rb, line 21 def initialize(course, start_time, end_time, location) @course_title = course @start_time = start_time @end_time = end_time @location = location end
Public Instance Methods
duration()
click to toggle source
Returns the duration of the period in minutes of the period @return [Integer] duration in minutes
# File lib/rhs-schedule/period.rb, line 39 def duration ((@end_time - @start_time) * 24 * 60).to_i end
long_location()
click to toggle source
# File lib/rhs-schedule/period.rb, line 33 def long_location return "Room #{@location}" if Float(@location) rescue @location end
to_s()
click to toggle source
Returns a short summary of the period including subject, location, and duration with times
# File lib/rhs-schedule/period.rb, line 29 def to_s "#{@course_title} in #{@location} for #{duration} minutes (#{start_time.strftime(TIME_FORMAT)} to #{end_time.strftime(TIME_FORMAT)})" end