Class: DoubleEntry::Reporting::TimeRange Private
- Inherits:
-
Object
- Object
- DoubleEntry::Reporting::TimeRange
- Defined in:
- lib/double_entry/reporting/time_range.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Attribute Summary collapse
- #day ⇒ Object readonly private
- #finish ⇒ Object readonly private
- #hour ⇒ Object readonly private
- #month ⇒ Object readonly private
- #range_type ⇒ Object readonly private
- #start ⇒ Object readonly private
- #week ⇒ Object readonly private
- #year ⇒ Object readonly private
Class Method Summary collapse
- .make(options = {}) ⇒ Object private
- .range_from_time_for_period(start_time, period_name) ⇒ Object private
Instance Method Summary collapse
- #human_readable_name ⇒ Object private
- #include?(time) ⇒ Boolean private
-
#initialize(options) ⇒ TimeRange
constructor
private
A new instance of TimeRange.
- #key ⇒ Object private
Constructor Details
#initialize(options) ⇒ TimeRange
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TimeRange.
44 45 46 47 48 |
# File 'lib/double_entry/reporting/time_range.rb', line 44 def initialize() @year = [:year] @range_type = [:range_type] || :normal @month = @week = @day = @hour = nil end |
Instance Attribute Details
#day ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/double_entry/reporting/time_range.rb', line 6 def day @day end |
#finish ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/time_range.rb', line 5 def finish @finish end |
#hour ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/double_entry/reporting/time_range.rb', line 6 def hour @hour end |
#month ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/double_entry/reporting/time_range.rb', line 6 def month @month end |
#range_type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/double_entry/reporting/time_range.rb', line 6 def range_type @range_type end |
#start ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/time_range.rb', line 5 def start @start end |
#week ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/double_entry/reporting/time_range.rb', line 6 def week @week end |
#year ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/double_entry/reporting/time_range.rb', line 6 def year @year end |
Class Method Details
.make(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/double_entry/reporting/time_range.rb', line 8 def self.make( = {}) @options = case when [:year] && [:week] && [:day] && [:hour] HourRange.new() when [:year] && [:week] && [:day] DayRange.new() when [:year] && [:week] WeekRange.new() when [:year] && [:month] MonthRange.new() when [:year] YearRange.new() else fail "Invalid range information #{}" end end |
.range_from_time_for_period(start_time, period_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |
Instance Method Details
#human_readable_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 |
# 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) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 |
# File 'lib/double_entry/reporting/time_range.rb', line 39 def include?(time) time >= @start && time <= @finish end |
#key ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/double_entry/reporting/time_range.rb', line 50 def key "#{@year}:#{@month}:#{@week}:#{@day}:#{@hour}" end |