Sha256: 4d8e56149aaa1e43b1550ce6aa6b0fd8680062cd3c6ec712240929443ef6a31b

Contents?: true

Size: 474 Bytes

Versions: 2

Compression:

Stored size: 474 Bytes

Contents

require "time"

module Twitch
  class Stream
    attr_reader :id, :user_id, :game_id, :community_ids, :type, :title, :viewer_count, :started_at, :language, :thumbnail_url
    DATE_ATTRIBUTES = [:started_at]

    def initialize(attributes = {})
      attributes.each do |k, v|
        if DATE_ATTRIBUTES.include?(k.to_sym)
          instance_variable_set("@#{k}", Time.parse(v))
        else
          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.1.0 lib/twitch/stream.rb
twitch-api-0.0.2 lib/twitch/stream.rb