Sha256: 1034d34a01cd5c2efedfd5a71480d09611ed0ff0602a0657b948b4a6869d009e

Contents?: true

Size: 1.07 KB

Versions: 18

Compression:

Stored size: 1.07 KB

Contents

require "active_support/inflector"

module OpenTok
  # Represents information about a stream in an OpenTok session.
  #
  # @attr [string] id
  #   The stream ID.
  #
  # @attr [string] name
  #   The name of the stream.

  # @attr [string] videoType
  #   The videoType property is either "camera" or "screen".
  #
  # @attr [array] layoutClassList
  #   An array of the layout classes for the stream.
  class Stream

    # @private
    def initialize(json)
      # TODO: validate json fits schema
      @json = json
    end

    # A JSON-encoded string representation of the stream.
    def to_json
      @json.to_json
    end


    # @private ignore
    def method_missing(method, *args, &block)
      camelized_method = method.to_s.camelize(:lower)
      if @json.has_key? camelized_method and args.empty?
        # TODO: convert create_time method call to a Time object
        if camelized_method == 'outputMode'
          @json[camelized_method].to_sym
        else
          @json[camelized_method]
        end
      else
        super method, *args, &block
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
opentok-4.10.0 lib/opentok/stream.rb
opentok-4.9.0 lib/opentok/stream.rb
opentok-4.8.1 lib/opentok/stream.rb
opentok-4.8.0 lib/opentok/stream.rb
opentok-4.7.1 lib/opentok/stream.rb
opentok-4.7.0 lib/opentok/stream.rb
opentok-4.6.0 lib/opentok/stream.rb
opentok-4.5.1 lib/opentok/stream.rb
opentok-4.5.0 lib/opentok/stream.rb
opentok-4.4.0 lib/opentok/stream.rb
opentok-4.3.0 lib/opentok/stream.rb
opentok-4.2.0 lib/opentok/stream.rb
opentok-4.1.2 lib/opentok/stream.rb
opentok-4.1.1 lib/opentok/stream.rb
opentok-4.1.0 lib/opentok/stream.rb
opentok-4.0.1 lib/opentok/stream.rb
opentok-4.0.0 lib/opentok/stream.rb
opentok-3.1.0 lib/opentok/stream.rb