Class: TimeRounder::RoundedTime

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from LoadSchedule

#get_schedule

Instance Attribute Details

#timeObject

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

#rounded_timeObject

returns the DateTime/Time object on the correct quarter hour

[View source]

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