Class: Twb::ColumnField
- Includes:
- Comparable
- Defined in:
- lib/twb/columnfield.rb
Instance Attribute Summary collapse
-
#aggregation ⇒ Object
readonly
Returns the value of attribute aggregation.
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#autoColumn ⇒ Object
readonly
Returns the value of attribute autoColumn.
-
#calcField ⇒ Object
readonly
Returns the value of attribute calcField.
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#dataType ⇒ Object
readonly
Returns the value of attribute dataType.
-
#datatypeCustomized ⇒ Object
readonly
Returns the value of attribute datatypeCustomized.
-
#defaultFormat ⇒ Object
readonly
Returns the value of attribute defaultFormat.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
readonly
XML Attributes known to exist in TWB xml —————————————- aggregation aggregation-param alias auto-column caption datatype datatype-customized default-format default-role default-type hidden layered name param-domain-type pivot role semantic-role SplitFieldIndex SplitFieldOrigin type user-datatype value visual-totals.
-
#paramDomainType ⇒ Object
readonly
Returns the value of attribute paramDomainType.
-
#properties ⇒ Object
readonly
XML Attributes known to exist in TWB xml —————————————- aggregation aggregation-param alias auto-column caption datatype datatype-customized default-format default-role default-type hidden layered name param-domain-type pivot role semantic-role SplitFieldIndex SplitFieldOrigin type user-datatype value visual-totals.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#semanticRole ⇒ Object
readonly
Returns the value of attribute semanticRole.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uiname ⇒ Object
readonly
Returns the value of attribute uiname.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from TabClass
#ttlogfile, #ttlogfilename, #uuid
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #comment ⇒ Object
- #hasComment? ⇒ Boolean
- #id ⇒ Object
-
#initialize(fieldNode, datasource = nil) ⇒ ColumnField
constructor
A new instance of ColumnField.
- #load(nodeName) ⇒ Object
- #loadAliases ⇒ Object
- #loadCalcField ⇒ Object
-
#loadComment ⇒ Object
COMMENTED FIELDS ————————————– <column caption=‘Calculation1’ datatype=‘real’ name=‘’ role=‘measure’ type=‘quantitative’> <calculation class=‘tableau’ formula=‘[Formula Length] * 1.1’ /> <desc> <formatted-text> <run>THIS IS A COMMENT</run> </formatted-text> </desc> </column> <column datatype=‘string’ name=‘[Data Source Name (tech) (CalculatedFieldsReferencedFields.csv)]’ role=‘dimension’ type=‘nominal’> <desc> <formatted-text> <run>THIS IS A COMMENT</run> </formatted-text> </desc> </column>.
- #loadProperties ⇒ Object
- #to_s ⇒ Object
Methods inherited from TabClass
#docFile, #emit, #setDocFileName
Constructor Details
#initialize(fieldNode, datasource = nil) ⇒ ColumnField
Returns a new instance of ColumnField.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/twb/columnfield.rb', line 60 def initialize(fieldNode, datasource=nil) @datasource = datasource @node = fieldNode @name = load 'name' @caption = load 'caption' @uiname = @caption.nil? ? @name : @caption @dataType = load 'datatype' @userDataType = load 'user-datatype' @defaultFormat = load 'default-format' @paramDomainType = load 'param-domain-type' @role = load 'role' @type = load 'type' @value = load 'value' @alias = load 'alias' @semanticRole = load 'semantic-role' @aggregation = load 'aggregation' @autoColumn = load 'auto-column' @hidden = load 'hidden' @datatypeCustomized = load 'datatype-customized' @calcField = loadCalcField end |
Instance Attribute Details
#aggregation ⇒ Object (readonly)
Returns the value of attribute aggregation.
54 55 56 |
# File 'lib/twb/columnfield.rb', line 54 def aggregation @aggregation end |
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
54 55 56 |
# File 'lib/twb/columnfield.rb', line 54 def alias @alias end |
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
57 58 59 |
# File 'lib/twb/columnfield.rb', line 57 def aliases @aliases end |
#autoColumn ⇒ Object (readonly)
Returns the value of attribute autoColumn.
55 56 57 |
# File 'lib/twb/columnfield.rb', line 55 def autoColumn @autoColumn end |
#calcField ⇒ Object (readonly)
Returns the value of attribute calcField.
56 57 58 |
# File 'lib/twb/columnfield.rb', line 56 def calcField @calcField end |
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
51 52 53 |
# File 'lib/twb/columnfield.rb', line 51 def @caption end |
#dataType ⇒ Object (readonly)
Returns the value of attribute dataType.
52 53 54 |
# File 'lib/twb/columnfield.rb', line 52 def dataType @dataType end |
#datatypeCustomized ⇒ Object (readonly)
Returns the value of attribute datatypeCustomized.
55 56 57 |
# File 'lib/twb/columnfield.rb', line 55 def datatypeCustomized @datatypeCustomized end |
#defaultFormat ⇒ Object (readonly)
Returns the value of attribute defaultFormat.
52 53 54 |
# File 'lib/twb/columnfield.rb', line 52 def defaultFormat @defaultFormat end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
55 56 57 |
# File 'lib/twb/columnfield.rb', line 55 def hidden @hidden end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
51 52 53 |
# File 'lib/twb/columnfield.rb', line 51 def name @name end |
#node ⇒ Object (readonly)
XML Attributes known to exist in TWB xml
aggregation aggregation-param alias auto-column caption datatype datatype-customized default-format default-role default-type hidden layered name param-domain-type pivot role semantic-role SplitFieldIndex SplitFieldOrigin type user-datatype value visual-totals
50 51 52 |
# File 'lib/twb/columnfield.rb', line 50 def node @node end |
#paramDomainType ⇒ Object (readonly)
Returns the value of attribute paramDomainType.
52 53 54 |
# File 'lib/twb/columnfield.rb', line 52 def paramDomainType @paramDomainType end |
#properties ⇒ Object (readonly)
XML Attributes known to exist in TWB xml
aggregation aggregation-param alias auto-column caption datatype datatype-customized default-format default-role default-type hidden layered name param-domain-type pivot role semantic-role SplitFieldIndex SplitFieldOrigin type user-datatype value visual-totals
50 51 52 |
# File 'lib/twb/columnfield.rb', line 50 def properties @properties end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
53 54 55 |
# File 'lib/twb/columnfield.rb', line 53 def role @role end |
#semanticRole ⇒ Object (readonly)
Returns the value of attribute semanticRole.
54 55 56 |
# File 'lib/twb/columnfield.rb', line 54 def semanticRole @semanticRole end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
53 54 55 |
# File 'lib/twb/columnfield.rb', line 53 def type @type end |
#uiname ⇒ Object (readonly)
Returns the value of attribute uiname.
51 52 53 |
# File 'lib/twb/columnfield.rb', line 51 def uiname @uiname end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
53 54 55 |
# File 'lib/twb/columnfield.rb', line 53 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
174 175 176 |
# File 'lib/twb/columnfield.rb', line 174 def <=>(other) @name <=> other.name end |
#comment ⇒ Object
104 105 106 |
# File 'lib/twb/columnfield.rb', line 104 def comment @commentLines ||= loadComment end |
#hasComment? ⇒ Boolean
137 138 139 140 |
# File 'lib/twb/columnfield.rb', line 137 def hasComment? loadComment if @commentLines.nil? @commentLines.empty? end |
#id ⇒ Object
82 83 84 |
# File 'lib/twb/columnfield.rb', line 82 def id @id ||= @id = @name.hash end |
#load(nodeName) ⇒ Object
86 87 88 89 90 |
# File 'lib/twb/columnfield.rb', line 86 def load nodeName attr = @node.attribute(nodeName) val = attr.nil? ? nil : attr.text.strip.gsub(/^\[|\]$/,'') return val end |
#loadAliases ⇒ Object
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/twb/columnfield.rb', line 146 def loadAliases @aliases = {} aliasNodes = @node.xpath('.//alias') aliasNodes.each do |node| key = node.attribute('key').text.gsub(/^"|"$/,'') value = node.attribute('value').text.gsub(/^"|"$/,'') @aliases[key] = value end return @aliases end |
#loadCalcField ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/twb/columnfield.rb', line 96 def loadCalcField if !@node.at_xpath('./calculation').nil? @calcField = Twb::CalculatedField.new @node, @datasource else @calcField = nil end end |
#loadComment ⇒ Object
COMMENTED FIELDS
<column caption=‘Calculation1’ datatype=‘real’ name=‘’ role=‘measure’ type=‘quantitative’>
<calculation class='tableau' formula='[Formula Length] * 1.1' />
<desc>
<formatted-text>
<run>THIS IS A COMMENT</run>
</formatted-text>
</desc>
</column> <column datatype=‘string’ name=‘[Data Source Name (tech) (CalculatedFieldsReferencedFields.csv)]’ role=‘dimension’ type=‘nominal’>
<desc>
<formatted-text>
<run>THIS IS A COMMENT</run>
</formatted-text>
</desc>
</column>
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/twb/columnfield.rb', line 125 def loadComment @commentLines = [] runs = @node.xpath('./desc/formatted-text/run') runs.each do |run| lines = run.text.split(/\n/) lines.each do |line| @commentLines << line end end return @commentLines end |
#loadProperties ⇒ Object
161 162 163 164 165 166 167 168 |
# File 'lib/twb/columnfield.rb', line 161 def loadProperties @properties= {} @node.attributes.each do |name,attr| @properties[name] = attr.value end @properties[:uiname] = @name return @properties end |
#to_s ⇒ Object
170 171 172 |
# File 'lib/twb/columnfield.rb', line 170 def to_s @name end |