class Bitmovin::Encoding::Encodings::StreamInput

Attributes

encoding_id[RW]
input_id[RW]
input_path[RW]
input_stream_id[RW]
position[RW]
selection_mode[RW]
stream_id[RW]

Public Class Methods

new(encoding_id, stream_id, hash) click to toggle source
# File lib/bitmovin/encoding/encodings/stream_input.rb, line 3
def initialize(encoding_id, stream_id, hash)
  @errors = []
  @encoding_id = encoding_id
  @stream_id = stream_id
  hash.each do |name, value|
    instance_variable_set("@#{ActiveSupport::Inflector.underscore(name)}", value)
  end
end

Public Instance Methods

errors() click to toggle source
# File lib/bitmovin/encoding/encodings/stream_input.rb, line 24
def errors
  @errors
end
invalid?() click to toggle source
# File lib/bitmovin/encoding/encodings/stream_input.rb, line 20
def invalid?
  !valid?
end
to_json(args) click to toggle source
# File lib/bitmovin/encoding/encodings/stream_input.rb, line 28
def to_json(args)
  collect_attributes.to_json(args)
end
valid?() click to toggle source
# File lib/bitmovin/encoding/encodings/stream_input.rb, line 15
def valid?
  validate!
  @errors.empty?
end

Private Instance Methods

collect_attributes() click to toggle source
# File lib/bitmovin/encoding/encodings/stream_input.rb, line 33
def collect_attributes
  val = Hash.new
  [:input_id, :input_path, :selection_mode, :position, :input_stream_id].each do |name|
    json_name = ActiveSupport::Inflector.camelize(name.to_s, false)
    value = instance_variable_get("@#{name}")
    if (!value.nil?)
      val[json_name] = instance_variable_get("@#{name}")
    end
  end
  val
end
validate!() click to toggle source
# File lib/bitmovin/encoding/encodings/stream_input.rb, line 44
def validate!
  return unless @input_stream_id.blank?

  @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?
  @errors << "position cannot be blank if selection_mode is not AUTO" if @position.blank? && @selection_mode != "AUTO"
end