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.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/twb/calculatedfield.rb', line 27

def initialize(calcNode, datasource=nil)
    @dataSource = datasource
    @node       = calcNode
    # -- 

    @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)
end

Instance Attribute Details

#calculationObject (readonly)

Returns the value of attribute calculation.



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

def calculation
  @calculation
end

#captionObject (readonly)

Returns the value of attribute caption.



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

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.



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

def datatype
  @datatype
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

#roleObject (readonly)

Returns the value of attribute role.



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

def role
  @role
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#uinameObject (readonly)

Returns the value of attribute uiname.



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

def uiname
  @uiname
end

Instance Method Details

#to_sObject



42
43
44
# File 'lib/twb/calculatedfield.rb', line 42

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