class DoubleEntry::Reporting::DayRange

Attributes

day[R]
week[R]
year[R]

Public Class Methods

from_time(time) click to toggle source
# File lib/double_entry/reporting/day_range.rb, line 18
def self.from_time(time)
  week_range = WeekRange.from_time(time)
  DayRange.new(:year => week_range.year, :week => week_range.week, :day => time.wday == 0 ? 7 : time.wday)
end
new(options) click to toggle source
Calls superclass method
# File lib/double_entry/reporting/day_range.rb, line 7
def initialize(options)
  super options

  @week = options[:week]
  @day = options[:day]
  week_range = WeekRange.new(options)

  @start = week_range.start + (options[:day] - 1).days
  @finish = @start.end_of_day
end

Public Instance Methods

==(other) click to toggle source
# File lib/double_entry/reporting/day_range.rb, line 31
def ==(other)
  week == other.week &&
    year == other.year &&
    day == other.day
end
next() click to toggle source
# File lib/double_entry/reporting/day_range.rb, line 27
def next
  DayRange.from_time(@start + 1.day)
end
previous() click to toggle source
# File lib/double_entry/reporting/day_range.rb, line 23
def previous
  DayRange.from_time(@start - 1.day)
end
to_s() click to toggle source
# File lib/double_entry/reporting/day_range.rb, line 37
def to_s
  start.strftime('%Y, %a %b %d')
end