class DoubleEntry::Reporting::TimeRange
Attributes
day[R]
finish[R]
hour[R]
month[R]
range_type[R]
start[R]
week[R]
year[R]
Public Class Methods
make(options = {})
click to toggle source
# File lib/double_entry/reporting/time_range.rb, line 8 def self.make(options = {}) @options = options case when options[:year] && options[:week] && options[:day] && options[:hour] HourRange.new(options) when options[:year] && options[:week] && options[:day] DayRange.new(options) when options[:year] && options[:week] WeekRange.new(options) when options[:year] && options[:month] MonthRange.new(options) when options[:year] YearRange.new(options) else fail "Invalid range information #{options}" end end
new(options)
click to toggle source
# File lib/double_entry/reporting/time_range.rb, line 44 def initialize(options) @year = options[:year] @range_type = options[:range_type] || :normal @month = @week = @day = @hour = nil end
range_from_time_for_period(start_time, period_name)
click to toggle source
# File lib/double_entry/reporting/time_range.rb, line 26 def self.range_from_time_for_period(start_time, period_name) case period_name when 'month' YearRange.from_time(start_time) when 'week' YearRange.from_time(start_time) when 'day' MonthRange.from_time(start_time) when 'hour' DayRange.from_time(start_time) end end
Public Instance Methods
human_readable_name()
click to toggle source
# File lib/double_entry/reporting/time_range.rb, line 54 def human_readable_name self.class.name.gsub('DoubleEntry::Reporting::', '').gsub('Range', '') end
include?(time)
click to toggle source
# File lib/double_entry/reporting/time_range.rb, line 39 def include?(time) time >= @start && time <= @finish end
key()
click to toggle source
# File lib/double_entry/reporting/time_range.rb, line 50 def key "#{@year}:#{@month}:#{@week}:#{@day}:#{@hour}" end