Class: Twb::Worksheet
- Inherits:
-
Object
- Object
- Twb::Worksheet
- Defined in:
- lib/twb/worksheet.rb
Constant Summary collapse
- @@hasher =
Digest::SHA256.new
Instance Attribute Summary collapse
-
#colFields ⇒ Object
readonly
Returns the value of attribute colFields.
-
#datasourceFields ⇒ Object
readonly
Returns the value of attribute datasourceFields.
-
#datasourcenames ⇒ Object
readonly
Returns the value of attribute datasourcenames.
-
#datasources ⇒ Object
readonly
Returns the value of attribute datasources.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#paneFields ⇒ Object
readonly
Returns the value of attribute paneFields.
-
#panesCount ⇒ Object
readonly
Returns the value of attribute panesCount.
-
#rowFields ⇒ Object
readonly
Returns the value of attribute rowFields.
Instance Method Summary collapse
- #addDSFields(fields, usage) ⇒ Object
- #datasource(name) ⇒ Object
-
#initialize(sheetNode) ⇒ Worksheet
constructor
A new instance of Worksheet.
- #loadDataSourceNames ⇒ Object
- #loadFields ⇒ Object
- #loadPaneFields ⇒ Object
- #loadRowColFields(type) ⇒ Object
Constructor Details
#initialize(sheetNode) ⇒ Worksheet
Returns a new instance of Worksheet.
29 30 31 32 33 34 35 |
# File 'lib/twb/worksheet.rb', line 29 def initialize sheetNode @node = sheetNode @name = @node.attr('name') loadDataSourceNames loadFields return self end |
Instance Attribute Details
#colFields ⇒ Object (readonly)
Returns the value of attribute colFields.
27 28 29 |
# File 'lib/twb/worksheet.rb', line 27 def colFields @colFields end |
#datasourceFields ⇒ Object (readonly)
Returns the value of attribute datasourceFields.
27 28 29 |
# File 'lib/twb/worksheet.rb', line 27 def datasourceFields @datasourceFields end |
#datasourcenames ⇒ Object (readonly)
Returns the value of attribute datasourcenames.
25 26 27 |
# File 'lib/twb/worksheet.rb', line 25 def datasourcenames @datasourcenames end |
#datasources ⇒ Object (readonly)
Returns the value of attribute datasources.
25 26 27 |
# File 'lib/twb/worksheet.rb', line 25 def datasources @datasources end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
27 28 29 |
# File 'lib/twb/worksheet.rb', line 27 def fields @fields end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/twb/worksheet.rb', line 25 def name @name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
25 26 27 |
# File 'lib/twb/worksheet.rb', line 25 def node @node end |
#paneFields ⇒ Object (readonly)
Returns the value of attribute paneFields.
27 28 29 |
# File 'lib/twb/worksheet.rb', line 27 def paneFields @paneFields end |
#panesCount ⇒ Object (readonly)
Returns the value of attribute panesCount.
26 27 28 |
# File 'lib/twb/worksheet.rb', line 26 def panesCount @panesCount end |
#rowFields ⇒ Object (readonly)
Returns the value of attribute rowFields.
27 28 29 |
# File 'lib/twb/worksheet.rb', line 27 def rowFields @rowFields end |
Instance Method Details
#addDSFields(fields, usage) ⇒ Object
85 86 87 88 |
# File 'lib/twb/worksheet.rb', line 85 def addDSFields fields, usage fields.each do end end |
#datasource(name) ⇒ Object
50 51 52 |
# File 'lib/twb/worksheet.rb', line 50 def datasource name @datasources[name] end |
#loadDataSourceNames ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/twb/worksheet.rb', line 37 def loadDataSourceNames @datasources = {} dsNodes = @node.xpath('.//datasource') dsNodes.each do |dsn| ds = WorksheetDataSource.new dsn @datasources[ds.name] = ds end end |
#loadFields ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/twb/worksheet.rb', line 63 def loadFields # puts "WORKSHEET loadFields" @fields = {} @datasourceFields = {} dsNodes = @node.xpath('.//datasource-dependencies') dsNodes.each do |dsn| dsName = dsn.attribute('datasource').text dsFields = @datasourceFields[dsName] = Set.new fieldNodes = dsn.xpath('./column') fieldNodes.each do |fn| dsFields.add WorksheetField.new fn, dsName end end @fields[:dsfields] = @datasourceFields # <rows>([DATA Connection (copy 2)].[none:JIRA HARVEST Correspondence Name:nk] / [DATA Connection (copy 2)].[none:CreatedDate (Issue) (DAY):ok])</rows> # <cols>[DATA Connection (copy 2)].[:Measure Names]</cols> @rowFields ||= loadRowColFields(:rows) # returns map of data source => (Set of) field names @fields[:rows] = @rowFields @colFields ||= loadRowColFields(:cols) # returns map of data source => (Set of) field names @fields[:cols] = @colFields end |
#loadPaneFields ⇒ Object
112 113 114 115 |
# File 'lib/twb/worksheet.rb', line 112 def loadPaneFields @paneFields = Set.new panes = @node.xpath('.//pane') end |
#loadRowColFields(type) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/twb/worksheet.rb', line 94 def loadRowColFields(type) fields = [] xpath = case type when :rows then './/rows' when :cols then './/cols' end return fields if xpath.nil? node = @node.at_xpath(xpath) RowsColsSplitter.new(node).fields.each do |fcode| fields << CodedField.new(fcode) end return fields end |