Class: Twitch::V2::Channel
- Inherits:
-
Object
- Object
- Twitch::V2::Channel
- Defined in:
- lib/kappa/channel.rb
Overview
Channels serve as the home location for a user's content. Channels have a stream, can run commercials, store videos, display information and status, and have a customized page including banners and backgrounds.
Instance Attribute Summary collapse
-
#background_url ⇒ String
readonly
URL for background image.
-
#banner_url ⇒ String
readonly
URL for banner image.
-
#created_at ⇒ Time
readonly
When the channel was created (UTC).
-
#display_name ⇒ String
readonly
User-friendly display name.
-
#game_name ⇒ String
readonly
Name of the primary game for this channel.
-
#id ⇒ Fixnum
readonly
Unique Twitch ID.
-
#logo_url ⇒ String
readonly
URL for the logo image.
-
#name ⇒ String
readonly
Unique Twitch name.
-
#status ⇒ String
readonly
Current status set by the channel's owner.
-
#teams ⇒ Array<Team>
readonly
The list of teams that this channel is associated with.
-
#updated_at ⇒ Time
readonly
When the channel was last updated (UTC).
-
#url ⇒ String
readonly
The URL for the channel's main page.
-
#video_banner_url ⇒ String
readonly
URL for the image shown when the stream is offline.
Instance Method Summary collapse
-
#followers(options = {}) {|follower| ... } ⇒ Array<User>?
Get the users following this channel.
-
#mature? ⇒ Boolean
Does this channel have mature content? This flag is specified by the owner of the channel.
-
#stream ⇒ Stream
Get the live stream associated with this channel.
-
#streaming? ⇒ Boolean
Does this channel currently have a live stream?.
-
#user ⇒ User
Get the owner of this channel.
-
#videos(options = {}) {|video| ... } ⇒ Array<Video>?
Get the videos for a channel, most recently created first.
Instance Attribute Details
#background_url ⇒ String (readonly)
Returns URL for background image.
132 133 134 |
# File 'lib/kappa/channel.rb', line 132 def background_url @background_url end |
#banner_url ⇒ String (readonly)
Returns URL for banner image.
137 138 139 |
# File 'lib/kappa/channel.rb', line 137 def @banner_url end |
#created_at ⇒ Time (readonly)
Returns When the channel was created (UTC).
142 143 144 |
# File 'lib/kappa/channel.rb', line 142 def created_at @created_at end |
#display_name ⇒ String (readonly)
Returns User-friendly display name. This name is used for the channel's page title.
148 149 150 |
# File 'lib/kappa/channel.rb', line 148 def display_name @display_name end |
#game_name ⇒ String (readonly)
Returns Name of the primary game for this channel.
153 154 155 |
# File 'lib/kappa/channel.rb', line 153 def game_name @game_name end |
#id ⇒ Fixnum (readonly)
Returns Unique Twitch ID.
127 128 129 |
# File 'lib/kappa/channel.rb', line 127 def id @id end |
#logo_url ⇒ String (readonly)
Returns URL for the logo image.
158 159 160 |
# File 'lib/kappa/channel.rb', line 158 def logo_url @logo_url end |
#name ⇒ String (readonly)
Returns Unique Twitch name.
164 165 166 |
# File 'lib/kappa/channel.rb', line 164 def name @name end |
#status ⇒ String (readonly)
Returns Current status set by the channel's owner.
169 170 171 |
# File 'lib/kappa/channel.rb', line 169 def status @status end |
#teams ⇒ Array<Team> (readonly)
Returns The list of teams that this channel is associated with. Not all channels have associated teams.
188 189 190 |
# File 'lib/kappa/channel.rb', line 188 def teams @teams end |
#updated_at ⇒ Time (readonly)
Returns When the channel was last updated (UTC). For example, when a stream is started or a channel's status is changed, the channel is updated.
174 175 176 |
# File 'lib/kappa/channel.rb', line 174 def updated_at @updated_at end |
#url ⇒ String (readonly)
Returns The URL for the channel's main page.
179 180 181 |
# File 'lib/kappa/channel.rb', line 179 def url @url end |
#video_banner_url ⇒ String (readonly)
Returns URL for the image shown when the stream is offline.
184 185 186 |
# File 'lib/kappa/channel.rb', line 184 def @video_banner_url end |
Instance Method Details
#followers(options = {}) {|follower| ... } ⇒ Array<User>?
The number of followers is potentially very large, so it's recommended that you specify a :limit
.
Get the users following this channel.
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/kappa/channel.rb', line 85 def followers( = {}, &block) name = CGI.escape(@name) return @query.connection.accumulate( :path => "channels/#{name}/follows", :json => 'follows', :sub_json => 'user', :create => -> hash { User.new(hash, @query) }, :limit => [:limit], :offset => [:offset], &block ) end |
#mature? ⇒ Boolean
Does this channel have mature content? This flag is specified by the owner of the channel.
41 42 43 |
# File 'lib/kappa/channel.rb', line 41 def mature? @mature end |
#stream ⇒ Stream
This incurs an additional web request.
Get the live stream associated with this channel.
49 50 51 |
# File 'lib/kappa/channel.rb', line 49 def stream @query.streams.get(@name) end |
#streaming? ⇒ Boolean
This makes a separate request to get the channel's stream. If you want to actually use the stream object, you should call #stream
instead.
Does this channel currently have a live stream?
57 58 59 |
# File 'lib/kappa/channel.rb', line 57 def streaming? !stream.nil? end |
#user ⇒ User
This incurs an additional web request.
Get the owner of this channel.
64 65 66 |
# File 'lib/kappa/channel.rb', line 64 def user @query.users.get(@name) end |
#videos(options = {}) {|video| ... } ⇒ Array<Video>?
This incurs additional web requests.
You can get videos directly from a channel name via Videos#for_channel.
Get the videos for a channel, most recently created first.
120 121 122 |
# File 'lib/kappa/channel.rb', line 120 def videos( = {}, &block) @query.videos.for_channel(@name, , &block) end |