Class: UnimatrixCLI::Alchemist::Rendition::ListCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/unimatrix_cli/alchemist/rendition/list_command.rb

Instance Method Summary collapse

Methods inherited from Command

available_commands, descendants, #initialize, #read_file, #validate, #validate_collection, #write

Methods included from UnimatrixParser

included

Constructor Details

This class inherits a constructor from UnimatrixCLI::Command

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/unimatrix_cli/alchemist/rendition/list_command.rb', line 11

def execute
  activity_proxies = find_renditions_and_activity_proxies
  
  if validate_collection( activity_proxies, 'Alchemist::ActivityProxy' )

    completed_proxies = activity_proxies.reject { | proxy | proxy.renditions.empty? }
    renditions = completed_proxies.map( &:renditions ).flatten

    if validate_collection( renditions, 'Alchemist::Rendition' )
      renditions.each do | rendition | 
        write( message: parse_rendition( rendition ) )
      end
      activity_proxies.each do | activity_proxy | 
        message = parse_activity_proxy( activity_proxy )
        write( message: message ) if message
      end
    else
      write( 
        message: "No completed, pending, or progressing " +
          "renditions found: #{ renditions.inspect }", 
        error: true 
      )
    end
  else
    write(
      message: "Error retrieving activity_proxies for " +
        "the given video: #{ activity_proxies.inspect }",
      error: true
    )
  end
end