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 played.
-
#user_id ⇒ Object
readonly
ID of the streaming user.
-
#user_name ⇒ Object
readonly
Display name of the streaming user.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ StreamMetadata
constructor
A new instance of StreamMetadata.
-
#method_missing(name, *args) ⇒ Object
Since more games can be supported in the future, this will ensure they will all be available.
- #respond_to_missing?(name) ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ StreamMetadata
Returns a new instance of StreamMetadata.
19 20 21 22 23 24 25 |
# File 'lib/twitch/stream_metadata.rb', line 19 def initialize(attributes = {}) @attributes = attributes @user_id = @attributes['user_id'] @user_name = @attributes['user_name'] @game_id = @attributes['game_id'] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Since more games can be supported in the future, this will ensure they will all be available.
29 30 31 32 33 34 35 |
# File 'lib/twitch/stream_metadata.rb', line 29 def method_missing(name, *args) name = name.to_s return super unless @attributes.key?(name) @attributes[name] end |
Instance Attribute Details
#game_id ⇒ Object (readonly)
ID of the game being played.
17 18 19 |
# File 'lib/twitch/stream_metadata.rb', line 17 def game_id @game_id end |
#user_id ⇒ Object (readonly)
ID of the streaming user.
13 14 15 |
# File 'lib/twitch/stream_metadata.rb', line 13 def user_id @user_id end |
#user_name ⇒ Object (readonly)
Display name of the streaming user.
15 16 17 |
# File 'lib/twitch/stream_metadata.rb', line 15 def user_name @user_name end |
Instance Method Details
#respond_to_missing?(name) ⇒ Boolean
37 38 39 40 41 |
# File 'lib/twitch/stream_metadata.rb', line 37 def respond_to_missing?(name) name = name.to_s @attributes.key?(name) ? true : super end |