Class: TableauServerClient::Resources::View

Inherits:
Resource
  • Object
show all
Defined in:
lib/tableau_server_client/resources/view.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

attr_reader, attributes, #attributes, #delete!, extract_attributes, extract_site_path, #initialize, location, #location, #path, plural_resource_name, resource_name, #server_url, #site_id, #site_path

Methods included from TableauServerClient::RequestBuilder

#build_request

Constructor Details

This class inherits a constructor from TableauServerClient::Resources::Resource

Instance Attribute Details

#content_urlObject (readonly)

Returns the value of attribute content_url.



9
10
11
# File 'lib/tableau_server_client/resources/view.rb', line 9

def content_url
  @content_url
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/tableau_server_client/resources/view.rb', line 9

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/tableau_server_client/resources/view.rb', line 9

def name
  @name
end

#owner=(value) ⇒ Object (writeonly)

Sets the attribute owner

Parameters:

  • value

    the value to set the attribute owner to.



10
11
12
# File 'lib/tableau_server_client/resources/view.rb', line 10

def owner=(value)
  @owner = value
end

#workbook_idObject (readonly)

Returns the value of attribute workbook_id.



9
10
11
# File 'lib/tableau_server_client/resources/view.rb', line 9

def workbook_id
  @workbook_id
end

Class Method Details

.from_collection_response(client, path, xml) ⇒ Object



18
19
20
21
22
23
# File 'lib/tableau_server_client/resources/view.rb', line 18

def self.from_collection_response(client, path, xml)
  xml.xpath("//xmlns:views/xmlns:view").each do |s|
    id = s['id']
    yield from_response(client, "#{path}/#{id}", s)
  end
end

.from_response(client, path, xml) ⇒ Object



12
13
14
15
16
# File 'lib/tableau_server_client/resources/view.rb', line 12

def self.from_response(client, path, xml)
  attrs = extract_attributes(xml)
  attrs['workbook_id'] = xml.xpath("xmlns:workbook")[0]['id']
  new(client, path, attrs)
end

Instance Method Details

#image(query_params: {}, file_path: nil) ⇒ Object



37
38
39
40
41
# File 'lib/tableau_server_client/resources/view.rb', line 37

def image(query_params: {}, file_path: nil)
  return @image if @iamge
  @image = client.download_image(location(query_params: query_params), file_path: file_path)
  @image
end

#webpage_pathObject



33
34
35
# File 'lib/tableau_server_client/resources/view.rb', line 33

def webpage_path
  content_url.gsub('/sheets/', '/')
end

#webpage_urlObject



29
30
31
# File 'lib/tableau_server_client/resources/view.rb', line 29

def webpage_url
  "#{server_url}#{content}/#/views/#{webpage_path}"
end

#workbookObject



25
26
27
# File 'lib/tableau_server_client/resources/view.rb', line 25

def workbook
  client.get Workbook.location(site_path, workbook_id)
end