Class: Twb::ColumnField
- Inherits:
-
Object
- Object
- 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.
-
#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.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #comment ⇒ Object
- #hasComment? ⇒ Boolean
-
#initialize(fieldNode, datasource = nil) ⇒ ColumnField
constructor
A new instance of ColumnField.
- #load(nodeName) ⇒ 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
Constructor Details
#initialize(fieldNode, datasource = nil) ⇒ ColumnField
Returns a new instance of ColumnField.
59 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 59 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 |
#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 @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
155 156 157 |
# File 'lib/twb/columnfield.rb', line 155 def <=>(other) @name <=> other.name end |
#comment ⇒ Object
100 101 102 |
# File 'lib/twb/columnfield.rb', line 100 def comment @commentLines ||= loadComment end |
#hasComment? ⇒ Boolean
133 134 135 136 |
# File 'lib/twb/columnfield.rb', line 133 def hasComment? loadComment if @commentLines.nil? @commentLines.empty? end |
#load(nodeName) ⇒ Object
82 83 84 85 86 |
# File 'lib/twb/columnfield.rb', line 82 def load nodeName attr = @node.attribute(nodeName) val = attr.nil? ? nil : attr.text.strip.gsub(/^\[|\]$/,'') return val end |
#loadCalcField ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/twb/columnfield.rb', line 92 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>
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/twb/columnfield.rb', line 121 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
142 143 144 145 146 147 148 149 |
# File 'lib/twb/columnfield.rb', line 142 def loadProperties @properties= {} @node.attributes.each do |name,attr| @properties[name] = attr.value end @properties[:uiname] = @name return @properties end |
#to_s ⇒ Object
151 152 153 |
# File 'lib/twb/columnfield.rb', line 151 def to_s @name end |