Class: TaskJuggler::Account

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

Overview

An Account is an object to record financial transactions. Alternatively, an Account can just be a container for a set of Accounts. In this case it cannot directly record any transactions.

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

Returns a new instance of Account.



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

def initialize(project, id, name, parent)
  super(project.accounts, id, name, parent)
  project.addAccount(self)

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

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



38
39
40
# File 'lib/taskjuggler/Account.rb', line 38

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

Instance Method Details

#scenario(scenarioIdx) ⇒ Object

Return a reference to the scenarioIdx-th scenario.



43
44
45
# File 'lib/taskjuggler/Account.rb', line 43

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