Class: Bitmovin::Encoding::Encodings::InputStreams::Trimming::TimeBased

Inherits:
Resource
  • Object
show all
Defined in:
lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#id

Instance Method Summary collapse

Methods inherited from Resource

#delete!, find, init, #init_instance, #inspect, list, #persisted?

Methods included from Helpers

#camelize_hash, #hash_to_struct, result, #result, #underscore_hash

Constructor Details

#initialize(encoding_id, hash = {}) ⇒ TimeBased

Returns a new instance of TimeBased.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 8

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

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def description
  @description
end

#durationObject

Returns the value of attribute duration.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def duration
  @duration
end

#encoding_idObject

Returns the value of attribute encoding_id.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def encoding_id
  @encoding_id
end

#errorsObject

Returns the value of attribute errors.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def errors
  @errors
end

#input_stream_idObject

Returns the value of attribute input_stream_id.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def input_stream_id
  @input_stream_id
end

#modified_atObject

Returns the value of attribute modified_at.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def modified_at
  @modified_at
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



5
6
7
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 5

def offset
  @offset
end

Instance Method Details

#invalid?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 26

def invalid?
  !valid?
end

#save!Object



22
23
24
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 22

def save!
  super if valid?
end

#valid?Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 30

def valid?
  validate!
  @errors.empty?
end

#validate!Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb', line 35

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