Sha256: 949a1e55cfb8cdecfeff1b7ee75433d5e6b30b83a87485e7187da7f04373d344

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

module Twitch
  # 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.
  class StreamMetadata
    # ID of the streaming user.
    attr_reader :user_id
    # ID of the game being playead.
    attr_reader :game_id

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitch-api-0.3.0 lib/twitch/stream_metadata.rb
twitch-api-0.2.0 lib/twitch/stream_metadata.rb