Class: MotionAL::Representations

Inherits:
Object
  • Object
show all
Defined in:
lib/motional/representations.rb

Overview

A collection of representations. Representations belongs to the asset.

Instance Method Summary collapse

Constructor Details

#initialize(asset) ⇒ Representations

Returns a new instance of Representations.

Parameters:



10
11
12
# File 'lib/motional/representations.rb', line 10

def initialize(asset)
  @asset = asset
end

Instance Method Details

#find_all {|representation| ... } ⇒ nil Also known as: each

Find and enumerate representations of the asset.

Examples:

asset.representations.find_all do |rep|
  p rep.filename
end

Yields:

  • (representation)

Yield Parameters:

Returns:

  • (nil)


46
47
48
49
50
51
52
# File 'lib/motional/representations.rb', line 46

def find_all(&block)
  @asset.representation_utis.each do |uti|
    find_by_uti(uti) do |rep|
      block.call(rep)
    end
  end
end

#find_by_uti(representation_uti) {|representation| ... } ⇒ nil

Find a representation by a specified representation UTI.

Examples:

asset.representations.find_by_uti(representation_uti) do |rep|
  p rep.filename
end

Parameters:

  • representation_uti (String)

    A representation’s UTI

Yields:

  • (representation)

Yield Parameters:

Returns:

  • (nil)


26
27
28
29
30
31
32
33
# File 'lib/motional/representations.rb', line 26

def find_by_uti(representation_uti, &block)
  al_rep = @asset.al_asset.representationForUTI(representation_uti)
  if al_rep
    block.call(Representation.new(@asset, al_rep))
  else
    nil # not found
  end
end