Parent

Class Index [+]

Quicksearch

TaskJuggler::AttributeBase

This class is the base for all property attribute types. Each property can have multiple attributes of different type. For each type, there must be a special Ruby class. Each of these classes must be derived from this class. The class holds information like a reference to the property that owns the attribute and the type of the attribute.

The class can track wheter the attribute value was provided by the project file, inherited from another property or computed during scheduling.

Attributes that are of an inherited type will be copied from a parent property or the global scope.

Attributes

property[R]
type[R]
provided[R]
inherited[R]

Public Class Methods

mode() click to toggle source

Return the current attribute setting mode.

    # File lib/taskjuggler/AttributeBase.rb, line 72
72:     def AttributeBase.mode
73:       @@mode
74:     end
new(property, type, container) click to toggle source

Create a new AttributeBase object. type specifies the specific type of the object. property is the PropertyTreeNode object this attribute belongs to.

    # File lib/taskjuggler/AttributeBase.rb, line 38
38:     def initialize(property, type, container)
39:       @type = type
40:       @property = property
41:       @container = container
42: 
43:       reset
44:     end
setMode(mode) click to toggle source

Change the @@mode. 0 means values are provided, 1 means values are inherited, any other value means calculated.

    # File lib/taskjuggler/AttributeBase.rb, line 78
78:     def AttributeBase.setMode(mode)
79:       @@mode = mode
80:     end

Public Instance Methods

get() click to toggle source

Return the attribute value.

     # File lib/taskjuggler/AttributeBase.rb, line 107
107:     def get
108:       @container.instance_variable_get(('@' + type.id).intern)
109:     end
Also aliased as: value
id() click to toggle source

Return the ID of the attribute.

    # File lib/taskjuggler/AttributeBase.rb, line 83
83:     def id
84:       type.id
85:     end
inherit(value) click to toggle source

Call this function to inherit value from the parent property. It is very important that the values are deep copied as they may be modified later on.

    # File lib/taskjuggler/AttributeBase.rb, line 66
66:     def inherit(value)
67:       @inherited = true
68:       @container.instance_variable_set(('@' + type.id).intern, value.deep_clone)
69:     end
name() click to toggle source

Return the name of the attribute.

    # File lib/taskjuggler/AttributeBase.rb, line 88
88:     def name
89:       type.name
90:     end
nil?() click to toggle source

Check whether the value is uninitialized or nil.

     # File lib/taskjuggler/AttributeBase.rb, line 115
115:     def nil?
116:       if (v = get).is_a?(Array)
117:         v.empty?
118:       else
119:         v.nil?
120:       end
121:     end
reset() click to toggle source

Reset the attribute value to the default value.

    # File lib/taskjuggler/AttributeBase.rb, line 47
47:     def reset
48:       @inherited = false
49:       # Flag that marks whether the value of this attribute was provided by the
50:       # user (in contrast to being calculated).
51:       @provided = false
52:       # If type is an AttributeDefinition, create the initial value according
53:       # to the specified default for this type. Otherwise type is the initial
54:       # value.
55:       if @type.is_a?(AttributeDefinition)
56:         @container.instance_variable_set(('@' + type.id).intern,
57:                                          @type.default.deep_clone)
58:       else
59:         @container.instance_variable_set(('@' + type.id).intern, @type)
60:       end
61:     end
set(value) click to toggle source

Set the value of the attribute. Depending on the mode we are in, the flags are updated accordingly.

     # File lib/taskjuggler/AttributeBase.rb, line 94
 94:     def set(value)
 95:       case @@mode
 96:         when 0
 97:           @provided = true
 98:         when 1
 99:           @inherited = true
100:       end
101:       # Store the value in an instance variable in the PropertyTreeNode or
102:       # ScenarioData object referred to by @container.
103:       @container.instance_variable_set(('@' + type.id).intern, value)
104:     end
to_num() click to toggle source
     # File lib/taskjuggler/AttributeBase.rb, line 128
128:     def to_num
129:       v = get
130:       if v.is_a?(Fixnum) || v.is_a?(Bignum) || v.is_a?(Float)
131:         v
132:       else
133:         nil
134:       end
135:     end
to_rti(query) click to toggle source
     # File lib/taskjuggler/AttributeBase.rb, line 148
148:     def to_rti(query)
149:       get.is_a?(RichTextIntermediate) ? !value : nil
150:     end
to_s(query = nil) click to toggle source

Return the value as String.

     # File lib/taskjuggler/AttributeBase.rb, line 124
124:     def to_s(query = nil)
125:       get.to_s
126:     end
to_sort() click to toggle source
     # File lib/taskjuggler/AttributeBase.rb, line 137
137:     def to_sort
138:       v = get
139:       if v.is_a?(Fixnum) || v.is_a?(Bignum) || v.is_a?(Float)
140:         v
141:       elsif v.respond_to?('to_s')
142:         v.to_s
143:       else
144:         nil
145:       end
146:     end
to_tjp() click to toggle source

Return the value in TJP file syntax.

     # File lib/taskjuggler/AttributeBase.rb, line 153
153:     def to_tjp
154:       @type.id + " " + get.to_s
155:     end
value() click to toggle source

For legacy purposes we provide another name for get().

Alias for: get

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.