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.
Return the current attribute setting mode.
# File lib/taskjuggler/AttributeBase.rb, line 72 72: def AttributeBase.mode 73: @@mode 74: end
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
Return the attribute value.
# File lib/taskjuggler/AttributeBase.rb, line 107 107: def get 108: @container.instance_variable_get(('@' + type.id).intern) 109: end
Return the ID of the attribute.
# File lib/taskjuggler/AttributeBase.rb, line 83 83: def id 84: type.id 85: end
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
Return the name of the attribute.
# File lib/taskjuggler/AttributeBase.rb, line 88 88: def name 89: type.name 90: end
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 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 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
# 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
# File lib/taskjuggler/AttributeBase.rb, line 148 148: def to_rti(query) 149: get.is_a?(RichTextIntermediate) ? !value : nil 150: end
Return the value as String.
# File lib/taskjuggler/AttributeBase.rb, line 124 124: def to_s(query = nil) 125: get.to_s 126: end
# 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
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
For legacy purposes we provide another name for get().
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.