Class: DoubleEntry::Reporting::DayRange Private
- Defined in:
- lib/double_entry/reporting/day_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.
Instance Attribute Summary collapse
- #day ⇒ Object readonly private
- #week ⇒ Object readonly private
- #year ⇒ Object readonly private
Attributes inherited from TimeRange
#finish, #hour, #month, #range_type, #start
Class Method Summary collapse
- .from_time(time) ⇒ Object private
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#initialize(options) ⇒ DayRange
constructor
private
A new instance of DayRange.
- #next ⇒ Object private
- #previous ⇒ Object private
- #to_s ⇒ Object private
Methods inherited from TimeRange
#human_readable_name, #include?, #key, make, range_from_time_for_period
Constructor Details
#initialize(options) ⇒ DayRange
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 DayRange.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/double_entry/reporting/day_range.rb', line 7 def initialize() super @week = [:week] @day = [:day] week_range = WeekRange.new() @start = week_range.start + ([:day] - 1).days @finish = @start.end_of_day 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.
5 6 7 |
# File 'lib/double_entry/reporting/day_range.rb', line 5 def day @day 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.
5 6 7 |
# File 'lib/double_entry/reporting/day_range.rb', line 5 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.
5 6 7 |
# File 'lib/double_entry/reporting/day_range.rb', line 5 def year @year end |
Class Method Details
.from_time(time) ⇒ 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.
18 19 20 21 |
# 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 |
Instance Method Details
#==(other) ⇒ 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.
31 32 33 |
# File 'lib/double_entry/reporting/day_range.rb', line 31 def ==(other) (self.week == other.week) and (self.year == other.year) and (self.day == other.day) end |
#next ⇒ 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.
27 28 29 |
# File 'lib/double_entry/reporting/day_range.rb', line 27 def next DayRange.from_time(@start + 1.day) end |
#previous ⇒ 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.
23 24 25 |
# File 'lib/double_entry/reporting/day_range.rb', line 23 def previous DayRange.from_time(@start - 1.day) end |
#to_s ⇒ 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.
35 36 37 |
# File 'lib/double_entry/reporting/day_range.rb', line 35 def to_s start.strftime('%Y, %a %b %d') end |