Sha256: b7afe38b718829d5e74da70558ad562feabd607e8dcd2dc0a91bb23bd88a86e8

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

module Bitmovin::Encoding::Encodings::InputStreams
  class Ingest < Bitmovin::Resource
    attr_accessor :encoding_id, :input_id, :input_path, :selection_mode, :position,
      :name, :description, :created_at, :modified_at, :errors

    def initialize(encoding_id, hash = {})
      hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash))
      @encoding_id = encoding_id

      init_instance(File.join("/v1/encoding/encodings/", encoding_id, "input-streams/ingest"))
      super(hash)

      @input_id = hash[:input_id]
      @input_path = hash[:input_path]
      @selection_mode = hash[:selection_mode]
      @position = hash[:position]

      @errors = []
    end

    def valid?
      validate!
      @errors.empty?
    end

    def invalid?
      !valid?
    end

    def errors
      @errors
    end

    def validate!
      @errors << "input_id cannot be blank" if @input_id.blank?
      @errors << "input_path cannot be blank" if @input_path.blank?
      @errors << "selection_mode cannot be blank" if @selection_mode.blank?

      if @position.blank? && @selection_mode != "AUTO"
        @errors << "position cannot be blank if selection_mode is not AUTO"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bitmovin-ruby-0.9.1 lib/bitmovin/encoding/encodings/input_streams/ingest.rb
bitmovin-ruby-0.9.0 lib/bitmovin/encoding/encodings/input_streams/ingest.rb