class Twb::Analysis::Sheets::WorksheetDataStructureCSVEmitter
Attributes
sheetCount[R]
attr_reader :csvFieldsFileName, :csvRecords
sheetNames[R]
attr_reader :csvFieldsFileName, :csvRecords
Public Class Methods
new()
click to toggle source
# File lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb, line 61 def initialize @csvPanesFileName = "Twb#{@@csvSheetPanesFileType}.csv" @csvPanesFile = CSV.open(@csvPanesFileName,'w') @csvPanesFile << @@csvSheetPanesHeader # -- @csvFieldsFileName = "Twb#{@@csvSheetFieldsFileType}.csv" @csvFieldsFile = CSV.open(@csvFieldsFileName,'w') @csvFieldsFile << @@csvSheetFieldsHeader # -- @twbsCnt = 0 @sheetsCnt = 0 @panesCnt = 0 @fieldsCnt = 0 end
Public Instance Methods
emitRowColFields(sheet, type, fields)
click to toggle source
# File lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb, line 167 def emitRowColFields sheet, type, fields fieldPos = 0 fields.each do |field| dsuiname = @twb.datasource(field.dataSource).uiname @csvFieldsFile << [ @fieldsCnt+=1, # 'Record #', @twb.name, # 'Workbook', @twb.dir, # 'Workbook Dir', sheet.name, # 'Worksheet', nil, # 'Pane #', dsuiname, # 'Data Source', field.dataSource, # 'Data Source (tech)', type, # 'Function', field.code, # 'Field Code', field.name, # 'Field Name (tech)', field.prefix, # 'Field Prefix', field.suffix, # 'Field Suffix', fieldPos+=1 ] end end
processPaneFields(sheet, node, paneID)
click to toggle source
# File lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb, line 135 def processPaneFields sheet, node, paneID encodedFields = node.xpath('.//encodings/*') # puts " flds : #{encodedFields.length} " fieldPos = 0 encodedFields.each do |ef| function = ef.name field = Twb::CodedField.new(ef.attribute('column').text) dsuiname = @twb.datasource(field.dataSource).uiname # puts " ef : <<#{function}>> #{ef} -> #{field} " @csvFieldsFile << [ @fieldsCnt+=1, # 'Record #', @twb.name, # 'Workbook', @twb.dir, # 'Workbook Dir', sheet, # 'Worksheet', paneID, # 'Pane #', dsuiname, # 'Data Source', field.dataSource, # 'Data Source (tech)', function, # 'Function', field.code, # 'Field Code', field.name, # 'Field Name (tech)', field.prefix, # 'Field Prefix', field.suffix, # 'Field Suffix', fieldPos+=1 ] end end
processPanes(sheet)
click to toggle source
# File lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb, line 101 def processPanes sheet pnodes = sheet.node.xpath('.//panes/pane') panesCnt = pnodes.length pnodes.each do |node| id = node.has_attribute?('id') ? node.attribute('id').text : '0' #-- if node.has_attribute?('x-axis-name') axistype = 'x' field = Twb::CodedField.new node.attribute('x-axis-name').text elsif node.has_attribute?('y-axis-name') axistype = 'y' field = Twb::CodedField.new node.attribute('y-axis-name').text else axistype = nil field = nil end #-- @csvPanesFile << [ @panesCnt+=1, @twb.name, # 'Workbook', @twb.dir, # 'Workbook Dir', sheet.name, # 'Worksheet', id, # 'Pane #', panesCnt, # 'Pane #of', axistype, # 'Axis Type', field.nil? ? ' ' : field.code, # 'Axis Field Code', field.nil? ? ' ' : field.dataSource, # 'Axis Field Code', field.nil? ? ' ' : field.prefix, # 'Axis Field Prefix', field.nil? ? ' ' : field.name, # 'Axis Field Name', field.nil? ? ' ' : field.suffix, # 'Axis Field Suffix' ] processPaneFields sheet.name, node, id end end
processRowsCols(sheet)
click to toggle source
# File lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb, line 162 def processRowsCols sheet emitRowColFields sheet, 'row', sheet.rowFields emitRowColFields sheet, 'col', sheet.colFields end
processTwb(twb)
click to toggle source
def self.csvFileType
@@csvFieldsFileType
end
# File lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb, line 84 def processTwb twb @twb = case twb when String then Twb::Workbook.new(twb) when Twb::Workbook then twb else raise ArgumentError.new("ERROR: #{twb} must be a String or Workbook, is a #{twb.class}") end # -- @sheetNames = SortedSet.new # -- sheets = @twb.worksheets sheets.each do |sheet| @sheetNames << sheet.name processPanes sheet processRowsCols sheet end end