Class: Twb::CalculatedField
- Defined in:
- lib/twb/calculatedfield.rb
Instance Attribute Summary collapse
-
#calcFields ⇒ Object
readonly
Returns the value of attribute calcFields.
-
#calculation ⇒ Object
readonly
Returns the value of attribute calculation.
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#dataSource ⇒ Object
readonly
Returns the value of attribute dataSource.
-
#datatype ⇒ Object
readonly
Returns the value of attribute datatype.
-
#groupMembers ⇒ Object
readonly
Returns the value of attribute groupMembers.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#isGroup ⇒ Object
readonly
Returns the value of attribute isGroup.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#propType ⇒ Object
readonly
Returns the value of attribute propType.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#uiname ⇒ Object
readonly
Returns the value of attribute uiname.
Attributes inherited from TabClass
#ttlogfile, #ttlogfilename, #type, #uuid
Instance Method Summary collapse
- #binValues(binName) ⇒ Object
- #formulaLines ⇒ Object
- #formulaResolved ⇒ Object
- #formulaResolvedLines ⇒ Object
- #id ⇒ Object
-
#initialize(calcNode, datasource = nil) ⇒ CalculatedField
constructor
A new instance of CalculatedField.
- #loadProperties ⇒ Object
-
#to_s ⇒ Object
def loadUUID dsn = @dataSource.nil? ? ‘NO DATASOURCE’ : dataSource.uuid @uuid = Digest::MD5.hexdigest(“#dsn::@name”).hash end.
Methods inherited from TabClass
#docFile, #emit, #setDocFileName
Constructor Details
#initialize(calcNode, datasource = nil) ⇒ CalculatedField
Returns a new instance of CalculatedField.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/twb/calculatedfield.rb', line 31 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 @propType = @node.attribute('type').text # n.b. 'type' is used as a proxy for class # -- @calculation = Twb::FieldCalculation.new(self, datasource) # -- @hidden = true if calcNode.has_attribute?('caption') @isGroup = !@node.at_xpath('./calculation[@class="categorical-bin"]').nil? end |
Instance Attribute Details
#calcFields ⇒ Object (readonly)
Returns the value of attribute calcFields.
27 28 29 |
# File 'lib/twb/calculatedfield.rb', line 27 def calcFields @calcFields end |
#calculation ⇒ Object (readonly)
Returns the value of attribute calculation.
27 28 29 |
# File 'lib/twb/calculatedfield.rb', line 27 def calculation @calculation end |
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
25 26 27 |
# File 'lib/twb/calculatedfield.rb', line 25 def caption @caption end |
#dataSource ⇒ Object (readonly)
Returns the value of attribute dataSource.
23 24 25 |
# File 'lib/twb/calculatedfield.rb', line 23 def dataSource @dataSource end |
#datatype ⇒ Object (readonly)
Returns the value of attribute datatype.
26 27 28 |
# File 'lib/twb/calculatedfield.rb', line 26 def datatype @datatype end |
#groupMembers ⇒ Object (readonly)
Returns the value of attribute groupMembers.
28 29 30 |
# File 'lib/twb/calculatedfield.rb', line 28 def groupMembers @groupMembers end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
29 30 31 |
# File 'lib/twb/calculatedfield.rb', line 29 def hidden @hidden end |
#isGroup ⇒ Object (readonly)
Returns the value of attribute isGroup.
28 29 30 |
# File 'lib/twb/calculatedfield.rb', line 28 def isGroup @isGroup end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/twb/calculatedfield.rb', line 25 def name @name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
24 25 26 |
# File 'lib/twb/calculatedfield.rb', line 24 def node @node end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
24 25 26 |
# File 'lib/twb/calculatedfield.rb', line 24 def properties @properties end |
#propType ⇒ Object (readonly)
Returns the value of attribute propType.
26 27 28 |
# File 'lib/twb/calculatedfield.rb', line 26 def propType @propType end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
26 27 28 |
# File 'lib/twb/calculatedfield.rb', line 26 def role @role end |
#uiname ⇒ Object (readonly)
Returns the value of attribute uiname.
25 26 27 |
# File 'lib/twb/calculatedfield.rb', line 25 def uiname @uiname end |
Instance Method Details
#binValues(binName) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/twb/calculatedfield.rb', line 73 def binValues binName values = [] binValue = "\"#{binName}\"" binNode = @node.at_xpath("./calculation[@class='categorical-bin']/bin[@value='#{binValue}']") unless binNode.nil? binNode.xpath('.//value').each do |v| values << v.text.gsub(/^['"]|['"]$/,'') end end return values end |
#formulaLines ⇒ Object
57 58 59 |
# File 'lib/twb/calculatedfield.rb', line 57 def formulaLines @calculation.formulaLines end |
#formulaResolved ⇒ Object
65 66 67 |
# File 'lib/twb/calculatedfield.rb', line 65 def formulaResolved @calculation.formulaResolved end |
#formulaResolvedLines ⇒ Object
61 62 63 |
# File 'lib/twb/calculatedfield.rb', line 61 def formulaResolvedLines @calculation.formulaResolvedLines end |
#id ⇒ Object
95 96 97 |
# File 'lib/twb/calculatedfield.rb', line 95 def id @id ||= @id = "#{@dataSource.uiname}::#{@uiname}" end |
#loadProperties ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/twb/calculatedfield.rb', line 85 def loadProperties @properties= {} @node.attributes.each do |name,attr| @properties[name] = attr.value end @properties[:uiname] = @uiname @properties[:uuid] = uuid return @properties end |
#to_s ⇒ Object
def loadUUID
dsn = @dataSource.nil? ? 'NO DATASOURCE' : dataSource.uuid
@uuid = Digest::MD5.hexdigest("#{dsn}::@name").hash
end
108 109 110 |
# File 'lib/twb/calculatedfield.rb', line 108 def to_s "%s(%s) => %s" % [uiname, name, @calculation.formulaFlat] end |