class Yt::Annotations::Promotion
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.
Public Class Methods
new(data = {})
click to toggle source
@param [Hash] data the Hash representation of the XML data returned by
YouTube for each annotation of a video.
# 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
Private Instance Methods
text_in(json)
click to toggle source
# File lib/yt/annotations/promotion.rb, line 20 def text_in(json) json.values_at('text_line_1', 'text_line_2').join(': ') end
to_link(url, data)
click to toggle source
# File lib/yt/annotations/promotion.rb, line 24 def to_link(url, data) new_window = url['target'] == 'new' {url: url['value'], new_window: new_window, type: :website} end