Sha256: 3b9e33ef274da4660d98d7572292f1b56e55813b6277c4b17349faa906b8b29e
Contents?: true
Size: 518 Bytes
Versions: 1
Compression:
Stored size: 518 Bytes
Contents
module Crono class Period def initialize(period, at: nil) @period = period @at_hour, @at_min = parse_at(at) if at end def next(since: nil) since ||= Time.now @period.since(since).change({hour: @at_hour, min: @at_min}.compact) end def parse_at(at) case at when String time = Time.parse(at) return time.hour, time.min when Hash return at[:hour], at[:min] else raise "Unknown 'at' format" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crono-0.5.2 | lib/crono/period.rb |