Class: VAST::Creative

Inherits:
Element show all
Defined in:
lib/vast/creative.rb

Overview

Contains the information related to a piece of creative.

Sequence

The Creative element takes an optional ???sequence??? attribute that indicates the suggested order in which the Creatives should be displayed. If two Creative elements are intended to be shown at the same time they should share the same sequence number.

Direct Known Subclasses

CompanionCreative, LinearCreative, NonLinearCreative

Instance Attribute Summary

Attributes inherited from Element

#source_node

Instance Method Summary (collapse)

Methods inherited from Element

#initialize

Constructor Details

This class inherits a constructor from VAST::Element

Instance Method Details

- (Object) ad



10
11
12
# File 'lib/vast/creative.rb', line 10

def ad
  Ad.create source_node.ancestors('Ad').first
end

- (Object) ad_id



18
19
20
# File 'lib/vast/creative.rb', line 18

def ad_id
  creative_node[:AdID]
end

- (Object) ad_parameters

Data to be passed into the video ad.



28
29
30
# File 'lib/vast/creative.rb', line 28

def ad_parameters
  source_node.at('AdParameters').content
end

- (Object) id



14
15
16
# File 'lib/vast/creative.rb', line 14

def id
  creative_node[:id]
end

- (Object) sequence

The preferred order in which multiple Creatives should be displayed



23
24
25
# File 'lib/vast/creative.rb', line 23

def sequence
  creative_node[:sequence]
end

- (Object) tracking_urls

Returns a hash, keyed by event name, containing an array of URIs to be called for each event.



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vast/creative.rb', line 33

def tracking_urls
  tracking_urls = {}
  source_node.xpath('.//Tracking').to_a.collect do |node|
    underscored_name = underscore(node[:event])
    if tracking_urls[underscored_name.to_sym]
       tracking_urls[underscored_name.to_sym] << URI.parse(node.content.strip)
    else
       tracking_urls[underscored_name.to_sym] = [URI.parse(node.content.strip)]
    end
  end
  tracking_urls
end