Class: Twitch::V2::Channels

Inherits:
Object
  • Object
show all
Defined in:
lib/kappa/channel.rb

Overview

Query class for finding channels.

See Also:

Instance Method Summary collapse

Instance Method Details

#get(channel_name) ⇒ Channel

Get a channel by name.

Examples:

c = Twitch.channels.get('day9tv')

Parameters:

  • channel_name (String)

    The name of the channel to get. This is the same as the stream or user name.

Returns:

  • (Channel)

    A valid Channel object if the channel exists, nil otherwise.



204
205
206
207
208
209
210
211
212
# File 'lib/kappa/channel.rb', line 204

def get(channel_name)
  name = CGI.escape(channel_name)

  # HTTP 422 can happen if the channel is associated with a Justin.tv account.
  Twitch::Status.map(404 => nil, 422 => nil) do
    json = @query.connection.get("channels/#{name}")
    Channel.new(json, @query)
  end
end