Module: ChronoLogger::Period

Included in:
TimeBasedLogDevice
Defined in:
lib/chrono_logger.rb

Constant Summary collapse

DAILY =
1
SiD =
24 * 60 * 60

Instance Method Summary collapse

Instance Method Details

#determine_period(format) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/chrono_logger.rb', line 31

def determine_period(format)
  case format
  when /%[SscXrT]/ then nil     # seconds
  when /%[MR]/ then nil         # minutes
  when /%[HklI]/ then nil       # hours
  when /%[dejDFvx]/ then DAILY
  else nil
  end
end

#next_start_period(now, period) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/chrono_logger.rb', line 41

def next_start_period(now, period)
  case period
  when DAILY
    Time.mktime(now.year, now.month, now.mday) + SiD
  else
    nil
  end
end