Class: Twitch::Clip

Inherits:
Object
  • Object
show all
Defined in:
lib/twitch/clip.rb

Overview

A small segment of a broadcast captured by another user.

Constant Summary collapse

DATE_ATTRIBUTES =

Fields to be converted from ISO 8601 string to a typed date.

[:created_at]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Clip

Returns a new instance of Clip.



32
33
34
35
36
37
38
39
40
# File 'lib/twitch/clip.rb', line 32

def initialize(attributes = {})
  attributes.each do |k, v|
    if DATE_ATTRIBUTES.include?(k.to_sym)
      instance_variable_set("@#{k}", Time.parse(v))
    else
      instance_variable_set("@#{k}", v)
    end
  end
end

Instance Attribute Details

#broadcaster_idObject (readonly)

(User) ID of the clip’s source broadcast.



24
25
26
# File 'lib/twitch/clip.rb', line 24

def broadcaster_id
  @broadcaster_id
end

#created_atObject (readonly)

Date the clip was created.



12
13
14
# File 'lib/twitch/clip.rb', line 12

def created_at
  @created_at
end

#creator_idObject (readonly)

(User) ID of the clip’s creator.



26
27
28
# File 'lib/twitch/clip.rb', line 26

def creator_id
  @creator_id
end

#embed_urlObject (readonly)

URL for embedding the clip.



18
19
20
# File 'lib/twitch/clip.rb', line 18

def embed_url
  @embed_url
end

#game_idObject (readonly)

ID of the game being played.



28
29
30
# File 'lib/twitch/clip.rb', line 28

def game_id
  @game_id
end

#idObject (readonly)

ID of the clip.



8
9
10
# File 'lib/twitch/clip.rb', line 8

def id
  @id
end

#languageObject (readonly)

Language of the originating broadcast.



22
23
24
# File 'lib/twitch/clip.rb', line 22

def language
  @language
end

#thumbnail_urlObject (readonly)

URL of the thumbnail image.



16
17
18
# File 'lib/twitch/clip.rb', line 16

def thumbnail_url
  @thumbnail_url
end

#titleObject (readonly)

Title of the clip.



10
11
12
# File 'lib/twitch/clip.rb', line 10

def title
  @title
end

#urlObject (readonly)

URL of the clip.



14
15
16
# File 'lib/twitch/clip.rb', line 14

def url
  @url
end

#video_idObject (readonly)

ID of the archived broadcast (may not be available).



30
31
32
# File 'lib/twitch/clip.rb', line 30

def video_id
  @video_id
end

#view_countObject (readonly)

Number of views.



20
21
22
# File 'lib/twitch/clip.rb', line 20

def view_count
  @view_count
end