Class: Twitch::V2::Game

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

Overview

Games are categories (e.g. League of Legends, Diablo 3) used by streams and channels. Games can be searched for by query.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#box_imagesImages (readonly)

Returns Set of images for the game's box art.

Returns:

  • (Images)

    Set of images for the game's box art.



68
69
70
# File 'lib/kappa/game.rb', line 68

def box_images
  @box_images
end

#channel_countFixnum (readonly)

Returns Total number of channels currently streaming this game on Twitch.

Examples:

802

Returns:

  • (Fixnum)

    Total number of channels currently streaming this game on Twitch.



76
77
78
# File 'lib/kappa/game.rb', line 76

def channel_count
  @channel_count
end

#giantbomb_idFixnum (readonly)

Returns Unique game ID for GiantBomb.com.

Examples:

24024

Returns:

  • (Fixnum)

    Unique game ID for GiantBomb.com.



65
66
67
# File 'lib/kappa/game.rb', line 65

def giantbomb_id
  @giantbomb_id
end

#idFixnum (readonly)

Returns Unique Twitch ID.

Examples:

21799

Returns:

  • (Fixnum)

    Unique Twitch ID.



55
56
57
# File 'lib/kappa/game.rb', line 55

def id
  @id
end

#logo_imagesImages (readonly)

Returns Set of images for the game's logo.

Returns:

  • (Images)

    Set of images for the game's logo.



71
72
73
# File 'lib/kappa/game.rb', line 71

def logo_images
  @logo_images
end

#nameString (readonly)

Returns User-friendly game name.

Examples:

"League of Legends"

Returns:

  • (String)

    User-friendly game name.



60
61
62
# File 'lib/kappa/game.rb', line 60

def name
  @name
end

#viewer_countFixnum (readonly)

Returns Total number of viewers across all channels currently watching this game on Twitch.

Examples:

68592

Returns:

  • (Fixnum)

    Total number of viewers across all channels currently watching this game on Twitch.



81
82
83
# File 'lib/kappa/game.rb', line 81

def viewer_count
  @viewer_count
end

Instance Method Details

#streams(options = {}) {|stream| ... } ⇒ Array<Stream>?

Get streams for this game.

Examples:

game.streams
game.streams(:embeddable => true, :limit => 20)
game.streams do |stream|
  next if stream.viewer_count < 1000
  puts stream.url
end

Parameters:

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

    Search criteria.

Options Hash (options):

  • :channel (Array<String, Channel, #name>)

    Only return streams for these channels. If a channel is not currently streaming, it is omitted. You must specify an array of channels or channel names.

  • :embeddable (Boolean) — default: nil

    If true, limit the streams to those that can be embedded. If false or nil, do not limit.

  • :hls (Boolean) — default: nil

    If true, limit the streams to those using HLS (HTTP Live Streaming). If false or nil, do not limit.

  • :limit (Fixnum) — default: nil

    Limit on the number of results returned.

  • :offset (Fixnum) — default: 0

    Offset into the result set to begin enumeration.

Yields:

  • Optional. If a block is given, each stream found is yielded.

Yield Parameters:

  • stream (Stream)

    Current stream.

Returns:

  • (Array<Stream>)

    Streams matching the specified criteria, if no block is given.

  • (nil)

    If a block is given.

Raises:

  • (ArgumentError)

    If :channel is not an array.

See Also:



48
49
50
# File 'lib/kappa/game.rb', line 48

def streams(options = {}, &block)
  @query.streams.find(options.merge(:game => @name), &block)
end