Class: DoubleEntry::DayRange
- Defined in:
- lib/double_entry/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.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/double_entry/day_range.rb', line 6 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.
4 5 6 |
# File 'lib/double_entry/day_range.rb', line 4 def day @day end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
4 5 6 |
# File 'lib/double_entry/day_range.rb', line 4 def week @week end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/double_entry/day_range.rb', line 4 def year @year end |
Class Method Details
.from_time(time) ⇒ Object
17 18 19 20 |
# File 'lib/double_entry/day_range.rb', line 17 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
30 31 32 |
# File 'lib/double_entry/day_range.rb', line 30 def ==(other) (self.week == other.week) and (self.year == other.year) and (self.day == other.day) end |
#next ⇒ Object
26 27 28 |
# File 'lib/double_entry/day_range.rb', line 26 def next DayRange.from_time(@start + 1.day) end |
#previous ⇒ Object
22 23 24 |
# File 'lib/double_entry/day_range.rb', line 22 def previous DayRange.from_time(@start - 1.day) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/double_entry/day_range.rb', line 34 def to_s start.strftime('%Y, %a %b %d') end |