Class: Yt::Annotations::Promotion

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/annotations/promotion.rb

Overview

A Promotion annotation. The CTA overlay is used more for paid campaigns because the video has to be attached to an adsense account to be used.

Instance Attribute Summary

Attributes inherited from Base

#ends_at, #link, #starts_at, #text

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Promotion

Returns a new instance of Promotion.

Parameters:

  • data (Hash) (defaults to: {})

    the Hash representation of the XML data returned by YouTube for each annotation of a video.



10
11
12
13
14
15
16
# File 'lib/yt/annotations/promotion.rb', line 10

def initialize(data = {})
  json = JSON.parse data['data']
  @text = text_in json
  @starts_at = json['start_ms'].to_i / 1000.0
  @ends_at = json['end_ms'].to_i / 1000.0
  @link = to_link data.fetch('action', {})['url'], data
end