Class: VAST::Document

Inherits:
Nokogiri::XML::Document
  • Object
show all
Defined in:
lib/vast/document.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(*args) ⇒ Object

Parse a VAST XML document



5
6
7
# File 'lib/vast/document.rb', line 5

def self.parse(*args)
  super(*args)
end

.parse!(*args) ⇒ Object

Same as parse, but raises InvalidDocumentError if document is not valid



10
11
12
13
14
# File 'lib/vast/document.rb', line 10

def self.parse!(*args)
  document = parse(*args)
  raise InvalidDocumentError unless document.valid?
  document
end

Instance Method Details

#adsObject

All ads in the document



24
25
26
27
28
# File 'lib/vast/document.rb', line 24

def ads
  self.root.xpath('.//Ad').to_a.collect do |node|
    Ad.create(node)
  end
end

#inline_adsObject

All inline ads



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

def inline_ads
  ads.select{ |ad| ad.kind_of?(VAST::InlineAd) }
end

#valid?Boolean

Checks whether document conforms to the VAST XML Schema Definitions, accessible at www.iab.net/iab_products_and_industry_services/508676/digitalvideo/vast

Returns:

  • (Boolean)


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

def valid?
  xsd = Nokogiri::XML::Schema(File.read(VAST_SCHEMA_XSD_FILE))
  xsd.valid?(self)
end

#wrapper_adsObject

All wrapper ads



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

def wrapper_ads
  ads.select{ |ad| ad.kind_of?(VAST::WrapperAd) }
end