Sha256: 9e3fd4f48931e2c746cdb60af492e084a66d38dd30cd236e413300efa4676490

Contents?: true

Size: 526 Bytes

Versions: 1

Compression:

Stored size: 526 Bytes

Contents

require "time"

module Twitch
  class Video
    DATE_ATTRIBUTES = [:created_at, :published_at]

    attr_reader :id, :title, :description, :language, :view_count, :created_at, 
      :published_at, :thumbnail_url, :type, :url, :user_id, :viewable, :duration

    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

1 entries across 1 versions & 1 rubygems

Version Path
twitch-api-0.1.0 lib/twitch/video.rb