Class: TimeRounder::RoundedTime
- Inherits:
-
Object
- Object
- TimeRounder::RoundedTime
- Includes:
- LoadSchedule
- Defined in:
- lib/time_rounder/rounded_time.rb
Overview
Round a Time/DateTime object to Quarter Hours 0, 15, 30, 45
Instance Attribute Summary collapse
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#rounded_time ⇒ Object
returns the DateTime/Time object on the correct quarter hour.
Methods included from LoadSchedule
Instance Attribute Details
permalink #time ⇒ Object
Returns the value of attribute time.
7 8 9 |
# File 'lib/time_rounder/rounded_time.rb', line 7 def time @time end |
Instance Method Details
permalink #rounded_time ⇒ Object
returns the DateTime/Time object on the correct quarter hour
13 14 15 16 17 18 19 |
# File 'lib/time_rounder/rounded_time.rb', line 13 def rounded_time number_to_add = magic_number seconds_to_remove = (time.sec + (minutes * 60)) self.time -= seconds_to_remove self.time += number_to_add time end |