Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/gb_work_day/core_ext/time.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#free? ⇒ boolean
Check if it is a work day.
- #minus_with_work_duration(other) ⇒ Object (also: #-)
-
#next_work_day ⇒ Time
Return next working day.
- #plus_with_work_duration(other) ⇒ Object (also: #+)
-
#work? ⇒ boolean
Check if it is a work day.
-
#work_time(week = nil) ⇒ Object
(also: #to_work, #to_work_time)
Get time object for calculating working days.
Instance Method Details
#free? ⇒ boolean
Check if it is a work day.
35 36 37 |
# File 'lib/gb_work_day/core_ext/time.rb', line 35 def free? default_week.free_day? self end |
#minus_with_work_duration(other) ⇒ Object Also known as: -
14 15 16 17 18 19 20 21 22 |
# File 'lib/gb_work_day/core_ext/time.rb', line 14 def minus_with_work_duration(other) if GBWorkDay::Duration === other plus_with_work_duration(-other) elsif GBWorkDay::Time === other - (other - self) else minus_without_work_duration(other) end end |
#next_work_day ⇒ Time
Return next working day
41 42 43 |
# File 'lib/gb_work_day/core_ext/time.rb', line 41 def next_work_day self + GBWorkDay::Duration.new(1, default_week) end |
#plus_with_work_duration(other) ⇒ Object Also known as: +
4 5 6 7 8 9 10 |
# File 'lib/gb_work_day/core_ext/time.rb', line 4 def plus_with_work_duration(other) if GBWorkDay::Duration === other other.since(self) else plus_without_work_duration(other) end end |
#work? ⇒ boolean
Check if it is a work day.
29 30 31 |
# File 'lib/gb_work_day/core_ext/time.rb', line 29 def work? default_week.work_day? self end |
#work_time(week = nil) ⇒ Object Also known as: to_work, to_work_time
Get time object for calculating working days
48 49 50 |
# File 'lib/gb_work_day/core_ext/time.rb', line 48 def work_time(week=nil) GBWorkDay::Time.from_time self, week end |