Sha256: 1ed27f75a4d4c3e2e71a824c7b61f87024d96d6d6deae65a76d74892955cddd0

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

module Bitmovin::Encoding::Encodings
  module InputStreams
    module Trimming
      class TimeBased < Bitmovin::Resource
        attr_accessor :encoding_id, :input_stream_id, :offset, :duration,
          :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/trimming/time-based"))
          super(hash)

          @offset = hash[:offset]
          @duration = hash[:duration]
          @input_stream_id = hash[:input_stream_id]

          @errors = []
        end

        def save!
          super if valid?
        end

        def invalid?
          !valid?
        end

        def valid?
          validate!
          @errors.empty?
        end

        def validate!
          @errors = []

          @errors << "Input Stream Id must be set" unless @input_stream_id
          @errors << "Offset must be set" unless @offset
          @errors << "Duration must be set" unless @duration
          @errors << "Duration must be greater than zero" if @duration.to_i <= 0

          @errors.flatten!
        end
      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/trimming/time_based.rb
bitmovin-ruby-0.9.0 lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb