Class: DoubleEntry::HourRange
- Defined in:
- lib/double_entry/hour_range.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#hour ⇒ Object
readonly
Returns the value of attribute hour.
-
#week ⇒ Object
readonly
Returns the value of attribute week.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Attributes inherited from TimeRange
#finish, #month, #range_type, #start
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(options) ⇒ HourRange
constructor
A new instance of HourRange.
- #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) ⇒ HourRange
Returns a new instance of HourRange.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/double_entry/hour_range.rb', line 6 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)
Returns the value of attribute day.
4 5 6 |
# File 'lib/double_entry/hour_range.rb', line 4 def day @day end |
#hour ⇒ Object (readonly)
Returns the value of attribute hour.
4 5 6 |
# File 'lib/double_entry/hour_range.rb', line 4 def hour @hour end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
4 5 6 |
# File 'lib/double_entry/hour_range.rb', line 4 def week @week end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/double_entry/hour_range.rb', line 4 def year @year end |
Class Method Details
.from_time(time) ⇒ Object
19 20 21 22 |
# File 'lib/double_entry/hour_range.rb', line 19 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
32 33 34 |
# File 'lib/double_entry/hour_range.rb', line 32 def ==(other) (self.week == other.week) and (self.year == other.year) and (self.day == other.day) and (self.hour == other.hour) end |
#next ⇒ Object
28 29 30 |
# File 'lib/double_entry/hour_range.rb', line 28 def next HourRange.from_time(@start + 1.hour) end |
#previous ⇒ Object
24 25 26 |
# File 'lib/double_entry/hour_range.rb', line 24 def previous HourRange.from_time(@start - 1.hour) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/double_entry/hour_range.rb', line 36 def to_s "#{start.hour}:00:00 - #{start.hour}:59:59" end |