Class: DoubleEntry::Reporting::DayRange
- Defined in:
- lib/double_entry/reporting/day_range.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#week ⇒ Object
readonly
Returns the value of attribute week.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Attributes inherited from TimeRange
#finish, #hour, #month, #range_type, #start
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(options) ⇒ DayRange
constructor
A new instance of DayRange.
- #next ⇒ Object
- #previous ⇒ Object
- #to_s ⇒ Object
Methods inherited from TimeRange
#human_readable_name, #include?, #key, make, range_from_time_for_period
Constructor Details
#initialize(options) ⇒ DayRange
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)
Returns the value of attribute day.
5 6 7 |
# File 'lib/double_entry/reporting/day_range.rb', line 5 def day @day end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
5 6 7 |
# File 'lib/double_entry/reporting/day_range.rb', line 5 def week @week end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
5 6 7 |
# File 'lib/double_entry/reporting/day_range.rb', line 5 def year @year end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 35 |
# File 'lib/double_entry/reporting/day_range.rb', line 31 def ==(other) week == other.week && year == other.year && day == other.day end |
#next ⇒ Object
27 28 29 |
# File 'lib/double_entry/reporting/day_range.rb', line 27 def next DayRange.from_time(@start + 1.day) end |
#previous ⇒ Object
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
37 38 39 |
# File 'lib/double_entry/reporting/day_range.rb', line 37 def to_s start.strftime('%Y, %a %b %d') end |