Class: Yt::Annotations::Card

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

Overview

A Card annotation is different from a Note annotation in the way data is represented in the XML under a new ‘data’ key with JSON-formatted content.

Direct Known Subclasses

Branding

Instance Attribute Summary

Attributes inherited from Base

#ends_at, #link, #starts_at, #text

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Card

Returns a new instance of Card.

Parameters:

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

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



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

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