Class: Twb::Dashboard

Inherits:
TabClass show all
Defined in:
lib/twb/dashboard.rb

Constant Summary collapse

@@hasher =
Digest::SHA256.new

Instance Attribute Summary collapse

Attributes inherited from TabClass

#properties, #ttlogfile, #ttlogfilename, #type, #uuid

Instance Method Summary collapse

Methods inherited from TabClass

#docFile, #emit, #setDocFileName

Constructor Details

#initialize(dashboardNode, twbworksheets) ⇒ Dashboard

Returns a new instance of Dashboard.


31
32
33
34
35
36
37
38
39
40
# File 'lib/twb/dashboard.rb', line 31

def initialize dashboardNode, twbworksheets
  @node     = dashboardNode
  @name     = @node.attr('name')
  @size     = @node.xpath('./size')
  @autosize = @size.empty?
  loadSize @size unless @autosize
  loadSheets twbworksheets
  @zonecount = @node.xpath('.//zone').length
  return self
end

Instance Attribute Details

#autosizeObject (readonly)

Returns the value of attribute autosize


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def autosize
  @autosize
end

#dimensionsObject (readonly)

Returns the value of attribute dimensions


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def dimensions
  @dimensions
end

#maxheightObject (readonly)

Returns the value of attribute maxheight


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def maxheight
  @maxheight
end

#maxwidthObject (readonly)

Returns the value of attribute maxwidth


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def maxwidth
  @maxwidth
end

#minheightObject (readonly)

Returns the value of attribute minheight


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def minheight
  @minheight
end

#minwidthObject (readonly)

Returns the value of attribute minwidth


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def minwidth
  @minwidth
end

#nameObject (readonly)

Returns the value of attribute name


26
27
28
# File 'lib/twb/dashboard.rb', line 26

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node


25
26
27
# File 'lib/twb/dashboard.rb', line 25

def node
  @node
end

#rangesizeObject (readonly)

Returns the value of attribute rangesize


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def rangesize
  @rangesize
end

#sizeObject (readonly)

Returns the value of attribute size


28
29
30
# File 'lib/twb/dashboard.rb', line 28

def size
  @size
end

#worksheetsObject (readonly)

Returns the value of attribute worksheets


27
28
29
# File 'lib/twb/dashboard.rb', line 27

def worksheets
  @worksheets
end

#zonecountObject (readonly)

Returns the value of attribute zonecount


29
30
31
# File 'lib/twb/dashboard.rb', line 29

def zonecount
  @zonecount
end

Instance Method Details

#idObject


42
43
44
# File 'lib/twb/dashboard.rb', line 42

def id
    @id ||= @id = @name.hash
end

#loadSheets(twbworksheets) ⇒ Object


46
47
48
49
50
51
52
53
54
55
56
# File 'lib/twb/dashboard.rb', line 46

def loadSheets twbworksheets
  @sheets = {}
  dsheets = @node.xpath('.//zone[@name]').to_a
  dsheets.each do |sheetNode|
    sheetname = sheetNode.attr('name')
    # early Tableau versions (e.g. 7), used "name=''" with text and other Dashboard components
    unless sheetname.eql?('') or sheetname.nil?
      @sheets[sheetname] = twbworksheets[sheetname]
    end
  end
end

#loadSize(size) ⇒ Object


66
67
68
69
70
71
72
73
# File 'lib/twb/dashboard.rb', line 66

def loadSize size
  @maxheight  = size.attr('maxheight')
  @maxwidth   = size.attr('maxwidth')
  @minheight  = size.attr('minheight')
  @minwidth   = size.attr('minwidth')
  @rangesize  = size.attr('rangesize')
  @dimensions = "%s:%s:%s:%s" % [@minwidth.to_s, @minheight.to_s, @maxwidth.to_s, @maxheight.to_s]
end

#worksheetNamesObject


62
63
64
# File 'lib/twb/dashboard.rb', line 62

def worksheetNames
  @sheets.keys
end