Class: Twitch::Video

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

Overview

A captured broadcast or portion of a broadcast.

Constant Summary collapse

DATE_ATTRIBUTES =
[:created_at, :published_at]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Video

Returns a new instance of Video.



36
37
38
39
40
41
42
43
44
# File 'lib/twitch/video.rb', line 36

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

#created_atObject (readonly)

Date the video was created.



19
20
21
# File 'lib/twitch/video.rb', line 19

def created_at
  @created_at
end

#descriptionObject (readonly)

Description of the video.



13
14
15
# File 'lib/twitch/video.rb', line 13

def description
  @description
end

#durationObject (readonly)

Duration of the video, in the format 0h0m0s



34
35
36
# File 'lib/twitch/video.rb', line 34

def duration
  @duration
end

#idObject (readonly)

ID of the video.



9
10
11
# File 'lib/twitch/video.rb', line 9

def id
  @id
end

#languageObject (readonly)

Language of the video.



15
16
17
# File 'lib/twitch/video.rb', line 15

def language
  @language
end

#published_atObject (readonly)

Date the video was published.



21
22
23
# File 'lib/twitch/video.rb', line 21

def published_at
  @published_at
end

#thumbnail_urlObject (readonly)

URL to the thumbnail image of the video.



23
24
25
# File 'lib/twitch/video.rb', line 23

def thumbnail_url
  @thumbnail_url
end

#titleObject (readonly)

Title of the video.



11
12
13
# File 'lib/twitch/video.rb', line 11

def title
  @title
end

#typeObject (readonly)

Type of the video (archive, highlight or upload).



25
26
27
# File 'lib/twitch/video.rb', line 25

def type
  @type
end

#urlObject (readonly)

URL of the video.



27
28
29
# File 'lib/twitch/video.rb', line 27

def url
  @url
end

#user_idObject (readonly)

ID of the user who uploaded/broadcasted the video.



29
30
31
# File 'lib/twitch/video.rb', line 29

def user_id
  @user_id
end

#view_countObject (readonly)

Number of views



17
18
19
# File 'lib/twitch/video.rb', line 17

def view_count
  @view_count
end

#viewableObject (readonly)

Viewability of the video (public or private)



31
32
33
# File 'lib/twitch/video.rb', line 31

def viewable
  @viewable
end