Class: Bitmovin::Encoding::Encodings::Sprite
- Defined in:
- lib/bitmovin/encoding/encodings/sprites/sprite.rb
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#height ⇒ Object
Returns the value of attribute height.
-
#outputs ⇒ Object
Returns the value of attribute outputs.
-
#sprite_name ⇒ Object
Returns the value of attribute sprite_name.
-
#vtt_name ⇒ Object
Returns the value of attribute vtt_name.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from Resource
#created_at, #description, #id, #modified_at, #name
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(encoding_id, stream_id, hash = {}) ⇒ Sprite
constructor
A new instance of Sprite.
- #invalid? ⇒ Boolean
- #save! ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
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, stream_id, hash = {}) ⇒ Sprite
Returns a new instance of Sprite.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 4 def initialize(encoding_id, stream_id, hash = {}) @errors = [] init_instance(File.join('/v1/encoding/encodings', encoding_id, 'streams', stream_id, 'sprites')) @encoding_id = encoding_id @stream_id = stream_id hsh = ActiveSupport::HashWithIndifferentAccess.new(underscore_hash(hash)) @height = hsh[:height] @width = hsh[:width] @sprite_name = hsh[:sprite_name] @vtt_name = hsh[:vtt_name] @distance = hsh[:distance] @outputs = (hsh[:outputs] || []).map {|output| Bitmovin::Encoding::StreamOutput.new(output)} end |
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance.
20 21 22 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 20 def distance @distance end |
#height ⇒ Object
Returns the value of attribute height.
20 21 22 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 20 def height @height end |
#outputs ⇒ Object
Returns the value of attribute outputs.
20 21 22 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 20 def outputs @outputs end |
#sprite_name ⇒ Object
Returns the value of attribute sprite_name.
20 21 22 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 20 def sprite_name @sprite_name end |
#vtt_name ⇒ Object
Returns the value of attribute vtt_name.
20 21 22 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 20 def vtt_name @vtt_name end |
#width ⇒ Object
Returns the value of attribute width.
20 21 22 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 20 def width @width end |
Instance Method Details
#errors ⇒ Object
28 29 30 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 28 def errors @errors end |
#invalid? ⇒ Boolean
41 42 43 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 41 def invalid? !valid? end |
#save! ⇒ Object
22 23 24 25 26 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 22 def save! if valid? super end end |
#valid? ⇒ Boolean
32 33 34 35 36 37 38 39 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 32 def valid? validate! unless @errors.empty? puts errors return false end true end |
#validate! ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bitmovin/encoding/encodings/sprites/sprite.rb', line 45 def validate! @errors = [] if @height == nil || @height < 0 @errors << 'The height has to be set and must be greater than 0' end if @width == nil || @width < 0 @errors << 'The width has to be set and must be greater than 0' end if @sprite_name == nil || @sprite_name.blank? @errors << 'The spriteName has to be set and must not be blank' end if @vtt_name == nil || @vtt_name.blank? @errors << 'The vttName has to be set and must not be blank' end if @distance < 0 @errors << 'The distance is not allowed to be less than 0' end @outputs.each do |output| @errors << output.errors unless output.valid? end @errors.flatten! end |