Class: Twitch::StreamMetadata

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

Overview

A set of metadata to provide additional information about a game being streamed.

Additional getters are assigned at initialization time, e.g.

self.hearthstone

has data when Hearthstone is being streamed.

Other games may be included, but will be set to nil if they aren’t the game currently being streamed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ StreamMetadata

Returns a new instance of StreamMetadata.

[View source]

15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/twitch/stream_metadata.rb', line 15

def initialize(attributes = {})
  @user_id = attributes['user_id']
  @game_id = attributes['game_id']

  # Since more games can be supported in the future,
  # this will ensure they will all be available.
  attributes.each do |k, v|
    unless instance_variables.include?("@#{k}".to_sym)
      self.class.send(:attr_reader, k.to_sym)
      instance_variable_set("@#{k}", v)
    end
  end
end

Instance Attribute Details

#game_idObject (readonly)

ID of the game being playead.


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

def game_id
  @game_id
end

#user_idObject (readonly)

ID of the streaming user.


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

def user_id
  @user_id
end