Class: VAST::CompanionCreative

Inherits:
Creative show all
Defined in:
lib/vast/companion_creative.rb

Overview

Commonly text, display ads, rich media, or skins that wrap around the video experience. These ads come in a number of sizes and shapes and typically run alongside or surrounding the video player.

Instance Attribute Summary

Attributes inherited from Element

#source_node

Instance Method Summary (collapse)

Methods inherited from Creative

#ad, #ad_id, #ad_parameters, #sequence, #tracking_urls

Methods inherited from Element

#initialize

Constructor Details

This class inherits a constructor from VAST::Element

Instance Method Details

- (Object) alt_text

Alternate text to be displayed when companion is rendered in HTML environment.



41
42
43
44
# File 'lib/vast/companion_creative.rb', line 41

def alt_text
  node = source_node.at('AltText')
  node.nil? ? nil : node.content
end

- (Object) api_framework

Defines the method to use for communication with the companion



31
32
33
# File 'lib/vast/companion_creative.rb', line 31

def api_framework
  source_node[:apiFramework]
end

- (Object) click_through_url

URI to open as destination page when user clicks on the video



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

def click_through_url
  URI.parse source_node.at('CompanionClickThrough').content.strip
end

- (Object) creative_type

Returns MIME type of static creative



58
59
60
61
62
# File 'lib/vast/companion_creative.rb', line 58

def creative_type
  if resource_type == :static
    source_node.at('StaticResource')[:creativeType]
  end
end

- (Object) expanded_height

Height in pixels of expanding companion ad when in expanded state



26
27
28
# File 'lib/vast/companion_creative.rb', line 26

def expanded_height
  source_node[:expandedHeight].to_i
end

- (Object) expanded_width

Width in pixels of expanding companion ad when in expanded state



21
22
23
# File 'lib/vast/companion_creative.rb', line 21

def expanded_width
  source_node[:expandedWidth].to_i
end

- (Object) height

Height in pixels of companion



16
17
18
# File 'lib/vast/companion_creative.rb', line 16

def height
  source_node[:height].to_i
end

- (Object) id



6
7
8
# File 'lib/vast/companion_creative.rb', line 6

def id
  source_node[:id]
end

- (Object) resource_html

Returns HTML text for html resource



75
76
77
78
79
# File 'lib/vast/companion_creative.rb', line 75

def resource_html
  if resource_type == :html
    source_node.at('HTMLResource').content
  end
end

- (Object) resource_type

Type of companion resource, returned as a symbol. Either :static, :iframe, or :html.



47
48
49
50
51
52
53
54
55
# File 'lib/vast/companion_creative.rb', line 47

def resource_type
  if source_node.at('StaticResource')
    :static
  elsif source_node.at('IFrameResource')
    :iframe
  elsif source_node.at('HTMLResource')
    :html
  end
end

- (Object) resource_url

Returns URI for static or iframe resource



65
66
67
68
69
70
71
72
# File 'lib/vast/companion_creative.rb', line 65

def resource_url
  case resource_type
  when :static
    URI.parse source_node.at('StaticResource').content.strip
  when :iframe
    URI.parse source_node.at('IFrameResource').content.strip
  end
end

- (Object) width

Width in pixels of companion



11
12
13
# File 'lib/vast/companion_creative.rb', line 11

def width
  source_node[:width].to_i
end