Class: TaskJuggler::Resource

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

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) ⇒ Resource

Returns a new instance of Resource.



21
22
23
24
25
26
27
28
29
# File 'lib/taskjuggler/Resource.rb', line 21

def initialize(project, id, name, parent)
  super(project.resources, id, name, parent)
  project.addResource(self)

  @data = Array.new(@project.scenarioCount, nil)
  @project.scenarioCount.times do |i|
    ResourceScenario.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, &block) ⇒ Object

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



40
41
42
# File 'lib/taskjuggler/Resource.rb', line 40

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

Instance Method Details

#book(scenarioIdx, sbIdx, task) ⇒ Object

Just a shortcut to avoid the slower calls via method_missing.



32
33
34
# File 'lib/taskjuggler/Resource.rb', line 32

def book(scenarioIdx, sbIdx, task)
  @data[scenarioIdx].book(sbIdx, task)
end

#query_dashboard(query) ⇒ Object



44
45
46
# File 'lib/taskjuggler/Resource.rb', line 44

def query_dashboard(query)
  dashboard(query)
end