class Blackcal::TimeOfDay
Represents a time of day (hour and min)
Attributes
hour[R]
@return [Integer] hour
min[R]
@return [Integer] minutes defaults to 0
Public Class Methods
new(hour, min = nil)
click to toggle source
Initialize time of day @param [Integer] hour @param [Integer, nil] min optional argument
# File lib/blackcal/time_of_day.rb, line 17 def initialize(hour, min = nil) @hour = hour @min = min || 0 end
Public Instance Methods
<=>(other)
click to toggle source
Compares two time of days @param [TimeOfDay, Integer] other if a number is passed it will be used as the hour @return [Integer] 1 if greater than, 0 if equal, -1 if less than
# File lib/blackcal/time_of_day.rb, line 25 def <=>(other) other_seconds = if other.is_a?(self.class) (other.hour * 60 * 60) + (other.min * 60) else other * 60 * 60 end seconds = (hour * 60 * 60) + (min * 60) seconds <=> other_seconds end