class VAST::Ad
Contains some combination of video, companions, and non-linear units for a single advertiser.
A single VAST
response may include multiple Ads from multiple advertisers. It will be up to the Video Player to determine the order, timing, placement, etc for the multiple ads. However, the player should generally respect the sequential order of the Ad
elements within a VAST
response.
The VAST
response does not contain information on the placement or timing of each ad. It is up to the Video Player to determine the optimal inclusion points of the ads.
Can either be a InlineAd
, meaning it contains all the elements necessary to display the visual experience, or a WrapperAd
, which points to a downstream VAST
document that must be requested from another server.
An Ad
may include one or more pieces of creative that are part of a single execution. For example, an Ad
may include a linear video element with a set of companion banners; this would be reflected by two Creative
elements, one LinearCreative
and one CompanionCreative
.
Public Class Methods
Creates proper ad type
# File lib/vast/ad.rb, line 21 def self.create(node) if node.at('InLine') InlineAd.new(node) elsif node.at('Wrapper') WrapperAd.new(node) else raise InvalidAdError end end
Public Instance Methods
Returns name of source ad server
# File lib/vast/ad.rb, line 41 def ad_system ad_system_node = source_node.at("AdSystem") if ad_system_node ad_system_node.content else raise InvalidAdError, "missing AdSystem node in Ad" end end
Returns an array containing all companion creatives.
# File lib/vast/ad.rb, line 77 def companion_creatives source_node.xpath('.//Creative/CompanionAds/Companion').to_a.collect do |node| CompanionCreative.new(node) end end
Returns URI to request if ad does not play due to error.
# File lib/vast/ad.rb, line 51 def error_url error_url_node = source_node.at("Error") URI.parse(error_url_node.content.strip) if error_url_node end
All extensions included with this ad.
# File lib/vast/ad.rb, line 97 def extensions source_node.xpath('.//Extension').to_a.collect do |node| Extension.new(node) end end
Ad
id, if indicated
# File lib/vast/ad.rb, line 32 def id source_node[:id] end
Each Ad
must contain at least one impression.
# File lib/vast/ad.rb, line 84 def impression URI.parse(source_node.at('Impression').content.strip) end
Array of all impressions available for this ad, excluding those specific to a particular creative.
# File lib/vast/ad.rb, line 90 def impressions source_node.xpath('.//Impression').to_a.collect do |node| URI.parse(node.content.strip) end end
This is a convenience method for when only the first piece of linear creative is needed. It’s common for an ad to contain only one piece of linear creative.
# File lib/vast/ad.rb, line 65 def linear_creative linear_creatives.first end
Returns an array containing all linear creatives.
# File lib/vast/ad.rb, line 57 def linear_creatives source_node.xpath('.//Creative/Linear').to_a.collect do |node| LinearCreative.new(node) end end
Returns an array containing all non linear creatives.
# File lib/vast/ad.rb, line 70 def non_linear_creatives source_node.xpath('.//Creative/NonLinearAds/NonLinear').to_a.collect do |node| NonLinearCreative.new(node) end end
# File lib/vast/ad.rb, line 36 def sequence source_node[:sequence] end