Class: TaskJuggler::ShiftAssignment
- Defined in:
- lib/taskjuggler/ShiftAssignments.rb
Overview
A ShiftAssignment associate a specific defined shift with a time interval where the shift should be active.
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#shiftScenario ⇒ Object
readonly
Returns the value of attribute shiftScenario.
Instance Method Summary collapse
-
#assigned?(date) ⇒ Boolean
Check if date is withing the assignment period.
-
#copy ⇒ Object
Return a deep copy of self.
- #hashKey ⇒ Object
-
#initialize(shiftScenario, interval) ⇒ ShiftAssignment
constructor
A new instance of ShiftAssignment.
-
#onLeave?(date) ⇒ Boolean
Returns true if the shift has a leave defined for the date.
-
#onShift?(date) ⇒ Boolean
Returns true if the shift has working hours defined for the date.
-
#overlaps?(iv) ⇒ Boolean
Return true if the iv interval overlaps with the assignment interval.
-
#replace?(date) ⇒ Boolean
Returns true if the shift is active and requests to replace global leave settings.
-
#to_s ⇒ Object
Primarily used for debugging.
Constructor Details
#initialize(shiftScenario, interval) ⇒ ShiftAssignment
Returns a new instance of ShiftAssignment.
27 28 29 30 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 27 def initialize(shiftScenario, interval) @shiftScenario = shiftScenario @interval = interval end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
25 26 27 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 25 def interval @interval end |
#shiftScenario ⇒ Object (readonly)
Returns the value of attribute shiftScenario.
24 25 26 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 24 def shiftScenario @shiftScenario end |
Instance Method Details
#assigned?(date) ⇒ Boolean
Check if date is withing the assignment period.
53 54 55 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 53 def assigned?(date) @interval.start <= date && date < @interval.end end |
#copy ⇒ Object
Return a deep copy of self.
37 38 39 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 37 def copy ShiftAssignment.new(@shiftScenario, TimeInterval.new(@interval)) end |
#hashKey ⇒ Object
32 33 34 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 32 def hashKey return "#{@shiftScenario.object_id}|#{@interval.start}|#{@interval.end}" end |
#onLeave?(date) ⇒ Boolean
Returns true if the shift has a leave defined for the date.
63 64 65 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 63 def onLeave?(date) @shiftScenario.onLeave?(date) end |
#onShift?(date) ⇒ Boolean
Returns true if the shift has working hours defined for the date.
58 59 60 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 58 def onShift?(date) @shiftScenario.onShift?(date) end |
#overlaps?(iv) ⇒ Boolean
Return true if the iv interval overlaps with the assignment interval.
42 43 44 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 42 def overlaps?(iv) @interval.overlaps?(iv) end |
#replace?(date) ⇒ Boolean
Returns true if the shift is active and requests to replace global leave settings.
48 49 50 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 48 def replace?(date) @interval.start <= date && date < @interval.end && @shiftScenario.replace? end |
#to_s ⇒ Object
Primarily used for debugging
68 69 70 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 68 def to_s "#{@shiftScenario.property.id} #{interval}" end |