Class: DoubleEntry::Reporting::HourRange Private
- Defined in:
- lib/double_entry/reporting/hour_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
- #hour ⇒ Object readonly private
- #week ⇒ Object readonly private
- #year ⇒ Object readonly private
Attributes inherited from TimeRange
#finish, #month, #range_type, #start
Class Method Summary collapse
- .from_time(time) ⇒ Object private
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#initialize(options) ⇒ HourRange
constructor
private
A new instance of HourRange.
- #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) ⇒ HourRange
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 HourRange.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/double_entry/reporting/hour_range.rb', line 7 def initialize() super @week = [:week] @day = [:day] @hour = [:hour] day_range = DayRange.new() @start = day_range.start + [:hour].hours @finish = @start.end_of_hour 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/hour_range.rb', line 5 def day @day 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.
5 6 7 |
# File 'lib/double_entry/reporting/hour_range.rb', line 5 def hour @hour 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/hour_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/hour_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.
20 21 22 23 |
# File 'lib/double_entry/reporting/hour_range.rb', line 20 def self.from_time(time) day = DayRange.from_time(time) HourRange.new :year => day.year, :week => day.week, :day => day.day, :hour => time.hour 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.
33 34 35 |
# File 'lib/double_entry/reporting/hour_range.rb', line 33 def ==(other) (self.week == other.week) and (self.year == other.year) and (self.day == other.day) and (self.hour == other.hour) 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.
29 30 31 |
# File 'lib/double_entry/reporting/hour_range.rb', line 29 def next HourRange.from_time(@start + 1.hour) 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.
25 26 27 |
# File 'lib/double_entry/reporting/hour_range.rb', line 25 def previous HourRange.from_time(@start - 1.hour) 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.
37 38 39 |
# File 'lib/double_entry/reporting/hour_range.rb', line 37 def to_s "#{start.hour}:00:00 - #{start.hour}:59:59" end |