Class: Twitch::StreamMetadata
- Inherits:
-
Object
- Object
- Twitch::StreamMetadata
- 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
-
#game_id ⇒ Object
readonly
ID of the game being playead.
-
#user_id ⇒ Object
readonly
ID of the streaming user.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ StreamMetadata
constructor
A new instance of StreamMetadata.
Constructor Details
permalink #initialize(attributes = {}) ⇒ StreamMetadata
Returns a new instance of StreamMetadata.
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
permalink #game_id ⇒ Object (readonly)
ID of the game being playead.
13 14 15 |
# File 'lib/twitch/stream_metadata.rb', line 13 def game_id @game_id end |
permalink #user_id ⇒ Object (readonly)
ID of the streaming user.
11 12 13 |
# File 'lib/twitch/stream_metadata.rb', line 11 def user_id @user_id end |