Class: DataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/tableauworkbook.rb

Overview

Tableau Workbook <datasource XML node

Constant Summary collapse

@@hasher =
Digest::SHA256.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dataSourceNode) ⇒ DataSource

Returns a new instance of DataSource.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/tableauworkbook.rb', line 38

def initialize dataSourceNode
  @node    = dataSourceNode
  @name    = @node.xpath('./@name').text
  @caption = @node.xpath('./@caption').text
  @uiname  = if @caption.nil? || @caption == '' then @name else @caption end
  # puts "DS:        n:#{@name}"
  # puts "     caption:#{@caption}"
  # puts "      c.len :#{@caption.length}"
  # puts "      c.nil?:#{@caption.nil?}"
  # puts "      uiname:#{@uiname}"
  # puts " "
  processConnection
end

Instance Attribute Details

#captionObject (readonly)

Returns the value of attribute caption.



36
37
38
# File 'lib/tableauworkbook.rb', line 36

def caption
  @caption
end

#classObject (readonly)

Returns the value of attribute class.



36
37
38
# File 'lib/tableauworkbook.rb', line 36

def class
  @class
end

#connectionObject (readonly)

Returns the value of attribute connection.



36
37
38
# File 'lib/tableauworkbook.rb', line 36

def connection
  @connection
end

#connHashObject (readonly)

Returns the value of attribute connHash.



36
37
38
# File 'lib/tableauworkbook.rb', line 36

def connHash
  @connHash
end

#nameObject (readonly)

Returns the value of attribute name.



36
37
38
# File 'lib/tableauworkbook.rb', line 36

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



36
37
38
# File 'lib/tableauworkbook.rb', line 36

def node
  @node
end

#uinameObject (readonly)

Returns the value of attribute uiname.



36
37
38
# File 'lib/tableauworkbook.rb', line 36

def uiname
  @uiname
end

Instance Method Details

#processConnectionObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/tableauworkbook.rb', line 52

def processConnection
  @connHash    = ''
  @connection  = @node.at_xpath('./connection')
  if !@connection.nil? then
    @class       = @connection.attribute('class').text
    dsAttributes = @node.xpath('./connection/@*')
    dsConnStr  = ''
    dsAttributes.each do |attr|
      dsConnStr += attr.text
      # Note: only collects non-'' attribute values
    end
    @connHash = Digest::MD5.hexdigest(dsConnStr)
  end
end