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.



27
28
29
30
# File 'lib/taskjuggler/ShiftAssignments.rb', line 27

def initialize(shiftScenario, interval)
  @shiftScenario = shiftScenario
  @interval = interval
end

Instance Attribute Details

#intervalObject

Returns the value of attribute interval.



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

def interval
  @interval
end

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

Returns:

  • (Boolean)


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

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

#copyObject

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

#hashKeyObject



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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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

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

#to_sObject

Primarily used for debugging



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

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