class Biz::Week

Attributes

week[R]

Public Class Methods

from_date(date) click to toggle source
# File lib/biz/week.rb, line 8
def self.from_date(date)
  new((date - Date.epoch).to_i / Time.week_days)
end
from_time(time) click to toggle source
# File lib/biz/week.rb, line 12
def self.from_time(time)
  from_date(time.to_date)
end
Also aliased as: since_epoch
new(week) click to toggle source
# File lib/biz/week.rb, line 22
def initialize(week)
  @week = Integer(week)
end
since_epoch(time)
Alias for: from_time

Public Instance Methods

+(other) click to toggle source
# File lib/biz/week.rb, line 42
def +(other)
  self.class.new(week + other.week)
end
downto(final_week) { |class.new(raw_week)| ... } click to toggle source
# File lib/biz/week.rb, line 34
def downto(final_week)
  return enum_for(:downto, final_week) unless block_given?

  week.downto(final_week.week).each do |raw_week|
    yield self.class.new(raw_week)
  end
end
start_date() click to toggle source
# File lib/biz/week.rb, line 26
def start_date
  Date.from_day(week * Time.week_days)
end
succ() click to toggle source
# File lib/biz/week.rb, line 30
def succ
  self.class.new(week.succ)
end

Private Instance Methods

<=>(other) click to toggle source
# File lib/biz/week.rb, line 52
def <=>(other)
  return unless other.is_a?(self.class)

  week <=> other.week
end