Class: TaskJuggler::Shift

Inherits:
PropertyTreeNode show all
Defined in:
lib/taskjuggler/Shift.rb

Overview

A shift is a definition of working hours for each day of the week. It may also contain a list of intervals that define off-duty periods or leaves.

Instance Attribute Summary

Attributes inherited from PropertyTreeNode

#adoptees, #children, #data, #id, #name, #parent, #project, #propertySet, #sequenceNo, #sourceFileInfo, #subId

Instance Method Summary collapse

Methods inherited from PropertyTreeNode

#[], #[]=, #addChild, #adopt, #all, #allLeaves, #ancestors, #attributeDefinition, #backupAttributes, #checkFailsAndWarnings, #container?, #deep_clone, #force, #fullId, #get, #getAdopted, #getAttribute, #getBSIndicies, #getIndicies, #inheritAttributes, #inherited, #isChildOf?, #kids, #leaf?, #level, #levelSeqNo, #logicalId, #modified?, #parents, #provided, #ptn, #query_alert, #query_alertmessages, #query_alertsummaries, #query_alerttrend, #query_children, #query_journal, #query_journalmessages, #query_journalsummaries, #removeReferences, #restoreAttributes, #root, #set, #to_s

Methods included from MessageHandler

#critical, #debug, #error, #fatal, #info, #warning

Constructor Details

#initialize(project, id, name, parent) ⇒ Shift

Returns a new instance of Shift.



23
24
25
26
27
28
29
30
31
# File 'lib/taskjuggler/Shift.rb', line 23

def initialize(project, id, name, parent)
  super(project.shifts, id, name, parent)
  project.addShift(self)

  @data = Array.new(@project.scenarioCount, nil)
  @project.scenarioCount.times do |i|
    ShiftScenario.new(self, i, @scenarioAttributes[i])
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(func, scenarioIdx = 0, *args) ⇒ Object

Many Shift functions are scenario specific. These functions are provided by the class ShiftScenario. In case we can’t find a function called for the Shift class we try to find it in ShiftScenario.



37
38
39
# File 'lib/taskjuggler/Shift.rb', line 37

def method_missing(func, scenarioIdx = 0, *args)
  @data[scenarioIdx].method(func).call(*args)
end

Instance Method Details

#scenario(scenarioIdx) ⇒ Object

Return a reference to the scenarioIdx-th scenario.



42
43
44
# File 'lib/taskjuggler/Shift.rb', line 42

def scenario(scenarioIdx)
  return @data[scenarioIdx]
end