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.
26 27 28 29 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 26 def initialize(shiftScenario, interval) @shiftScenario = shiftScenario @interval = interval end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
24 25 26 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 24 def interval @interval end |
#shiftScenario ⇒ Object (readonly)
Returns the value of attribute shiftScenario.
23 24 25 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 23 def shiftScenario @shiftScenario end |
Instance Method Details
#assigned?(date) ⇒ Boolean
Check if date is withing the assignment period.
52 53 54 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 52 def assigned?(date) @interval.start <= date && date < @interval.end end |
#copy ⇒ Object
Return a deep copy of self.
36 37 38 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 36 def copy ShiftAssignment.new(@shiftScenario, TimeInterval.new(@interval)) end |
#hashKey ⇒ Object
31 32 33 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 31 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.
62 63 64 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 62 def onLeave?(date) @shiftScenario.onLeave?(date) end |
#onShift?(date) ⇒ Boolean
Returns true if the shift has working hours defined for the date.
57 58 59 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 57 def onShift?(date) @shiftScenario.onShift?(date) end |
#overlaps?(iv) ⇒ Boolean
Return true if the iv interval overlaps with the assignment interval.
41 42 43 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 41 def overlaps?(iv) @interval.overlaps?(iv) end |
#replace?(date) ⇒ Boolean
Returns true if the shift is active and requests to replace global leave settings.
47 48 49 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 47 def replace?(date) @interval.start <= date && date < @interval.end && @shiftScenario.replace? end |
#to_s ⇒ Object
Primarily used for debugging
67 68 69 |
# File 'lib/taskjuggler/ShiftAssignments.rb', line 67 def to_s "#{@shiftScenario.property.id} #{interval}" end |