class TimeMath::Units::Week

@private

Public Class Methods

new() click to toggle source
Calls superclass method TimeMath::Units::Base::new
# File lib/time_math/units/week.rb, line 5
def initialize
  super(:week)
end

Public Instance Methods

floor(tm, span = 1) click to toggle source
# File lib/time_math/units/week.rb, line 9
def floor(tm, span = 1)
  span == 1 or
    raise NotImplementedError, 'For now, week only can floor to one'

  f = TimeMath.day.floor(tm)
  extra_days = tm.wday.zero? ? 6 : tm.wday - 1
  TimeMath.day.decrease(f, extra_days)
end
to_seconds(sz = 1) click to toggle source
# File lib/time_math/units/week.rb, line 18
def to_seconds(sz = 1)
  TimeMath.day.to_seconds(sz * 7)
end

Protected Instance Methods

_advance(tm, steps) click to toggle source
# File lib/time_math/units/week.rb, line 24
def _advance(tm, steps)
  TimeMath.day.advance(tm, steps * 7)
end
_decrease(tm, steps) click to toggle source
# File lib/time_math/units/week.rb, line 28
def _decrease(tm, steps)
  TimeMath.day.decrease(tm, steps * 7)
end