Class: Twb::CalculatedField

Inherits:
Object
  • Object
show all
Defined in:
lib/twb/calculatedfield.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(calcNode, datasource = nil) ⇒ CalculatedField

Returns a new instance of CalculatedField.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/twb/calculatedfield.rb', line 29

def initialize(calcNode, datasource=nil)
    @node       = calcNode
    @dataSource = datasource
    # -- 
    @caption    = calcNode.attribute('caption').text if calcNode.has_attribute?('caption')
    @name       = calcNode.attribute('name').text.gsub(/^\[/,'').gsub(/\]$/,'')
    @uiname     = caption.nil? ? @name : @caption
    # -- 
    @datatype    = @node.attribute('datatype').text
    @role        = @node.attribute('role').text
    @type        = @node.attribute('type').text
    # -- 
    @calculation = Twb::FieldCalculation.new(self, datasource)
    # -- 
    @hidden      = true if calcNode.has_attribute?('caption')
end

Instance Attribute Details

#calcFieldsObject (readonly)

Returns the value of attribute calcFields.



26
27
28
# File 'lib/twb/calculatedfield.rb', line 26

def calcFields
  @calcFields
end

#calculationObject (readonly)

Returns the value of attribute calculation.



26
27
28
# File 'lib/twb/calculatedfield.rb', line 26

def calculation
  @calculation
end

#captionObject (readonly)

Returns the value of attribute caption.



24
25
26
# File 'lib/twb/calculatedfield.rb', line 24

def caption
  @caption
end

#dataSourceObject (readonly)

Returns the value of attribute dataSource.



22
23
24
# File 'lib/twb/calculatedfield.rb', line 22

def dataSource
  @dataSource
end

#datatypeObject (readonly)

Returns the value of attribute datatype.



25
26
27
# File 'lib/twb/calculatedfield.rb', line 25

def datatype
  @datatype
end

#hiddenObject (readonly)

Returns the value of attribute hidden.



27
28
29
# File 'lib/twb/calculatedfield.rb', line 27

def hidden
  @hidden
end

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/twb/calculatedfield.rb', line 24

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



23
24
25
# File 'lib/twb/calculatedfield.rb', line 23

def node
  @node
end

#propertiesObject (readonly)

Returns the value of attribute properties.



23
24
25
# File 'lib/twb/calculatedfield.rb', line 23

def properties
  @properties
end

#roleObject (readonly)

Returns the value of attribute role.



25
26
27
# File 'lib/twb/calculatedfield.rb', line 25

def role
  @role
end

#typeObject (readonly)

Returns the value of attribute type.



25
26
27
# File 'lib/twb/calculatedfield.rb', line 25

def type
  @type
end

#uinameObject (readonly)

Returns the value of attribute uiname.



24
25
26
# File 'lib/twb/calculatedfield.rb', line 24

def uiname
  @uiname
end

Instance Method Details

#calcLinesObject



50
51
52
# File 'lib/twb/calculatedfield.rb', line 50

def calcLines
    @calculation.calcFields
end

#formulaLinesObject



54
55
56
# File 'lib/twb/calculatedfield.rb', line 54

def formulaLines
    @calculation.formulaLines
end

#formulaResolvedObject



62
63
64
# File 'lib/twb/calculatedfield.rb', line 62

def formulaResolved
    @calculation.formulaResolved
end

#formulaResolvedLinesObject



58
59
60
# File 'lib/twb/calculatedfield.rb', line 58

def formulaResolvedLines
    @calculation.formulaResolvedLines
end

#loadPropertiesObject



66
67
68
69
70
71
72
73
# File 'lib/twb/calculatedfield.rb', line 66

def loadProperties
  @properties= {}
  @node.attributes.each do |name,attr|
    @properties[name] = attr.value
  end
  @properties[:uiname] = @uiname
  return @properties
end

#to_sObject



75
76
77
# File 'lib/twb/calculatedfield.rb', line 75

def to_s
    "%s(%s) => %s" % [uiname, name, @calculation.formulaFlat]
end