Class: VAST::Document
- Inherits:
-
Nokogiri::XML::Document
- Object
- Nokogiri::XML::Document
- VAST::Document
- Defined in:
- lib/vast/document.rb
Class Method Summary collapse
-
.parse(*args) ⇒ Object
Parse a VAST XML document.
-
.parse!(*args) ⇒ Object
Same as parse, but raises InvalidDocumentError if document is not valid.
Instance Method Summary collapse
-
#ads ⇒ Object
All ads in the document.
-
#inline_ads ⇒ Object
All inline ads.
-
#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.
-
#wrapper_ads ⇒ Object
All wrapper ads.
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
#ads ⇒ Object
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_ads ⇒ Object
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
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 |