Class: TaskJuggler::ShiftAssignment

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#intervalObject

Returns the value of attribute interval.



24
25
26
# File 'lib/taskjuggler/ShiftAssignments.rb', line 24

def interval
  @interval
end

#shiftScenarioObject (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.

Returns:

  • (Boolean)


52
53
54
# File 'lib/taskjuggler/ShiftAssignments.rb', line 52

def assigned?(date)
  @interval.start <= date && date < @interval.end
end

#copyObject

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

#hashKeyObject



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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


47
48
49
# File 'lib/taskjuggler/ShiftAssignments.rb', line 47

def replace?(date)
  @interval.start <= date && date < @interval.end && @shiftScenario.replace?
end

#to_sObject

Primarily used for debugging



67
68
69
# File 'lib/taskjuggler/ShiftAssignments.rb', line 67

def to_s
  "#{@shiftScenario.property.id} #{interval}"
end