Sha256: 27d7254e862b4cfeeec3628d9edccb697b9018f39c07d9ce0ce69e3cb82decc1

Contents?: true

Size: 474 Bytes

Versions: 1

Compression:

Stored size: 474 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

    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.0.2 lib/twitch/video.rb