Class: AllTracks

Inherits:
Object
  • Object
show all
Defined in:
lib/live_set/live_set_all_tracks.rb

Instance Method Summary collapse

Constructor Details

#initialize(tracks) ⇒ AllTracks

Returns a new instance of AllTracks.



2
3
4
5
# File 'lib/live_set/live_set_all_tracks.rb', line 2

def initialize(tracks)
  @tracks = tracks
  @track_instances = tracks.map { |track| LiveAudioTrack.new track }
end

Instance Method Details

#all_frozenObject



7
8
9
# File 'lib/live_set/live_set_all_tracks.rb', line 7

def all_frozen
  @track_instances.all?(&:frozen)
end

#messageObject



11
12
13
14
15
16
17
# File 'lib/live_set/live_set_all_tracks.rb', line 11

def message
  if @tracks.empty?
    'No tracks'
  else
    summary + '  ' + @track_instances.map { |x| x.show_track(all_frozen) }.join("\n  ") # rubocop:disable Style/StringConcatenation
  end
end

#p3s_tx_msgObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/live_set/live_set_all_tracks.rb', line 23

def p3s_tx_msg
  return 'Ready for transfer to Push 3 Standalone'.green if ready_for_p3s

  response = []
  response << ' - Some tracks are not frozen.'.red unless all_frozen
  @track_instances.each do |track|
    track.audio_clips.each do |clip|
      response << " - Clip '#{clip.absolute_path}' has not been collected.".red unless clip.relative_path.start_with?('Samples/Imported/')
    end
  end
  response.reverse!
  response << 'Warning: This set should not be transferred to Push 3 Standalone.'.red
  response.reverse!
  response.join "\n"
end

#ready_for_p3sObject



19
20
21
# File 'lib/live_set/live_set_all_tracks.rb', line 19

def ready_for_p3s
  @track_instances.all?(&:clips_collected?) && all_frozen
end

#summaryObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/live_set/live_set_all_tracks.rb', line 39

def summary
  all_frozen_msg = all_frozen ? ' (All are frozen)'.yellow : ''
  total_size = @track_instances.sum(&:track_size)
  size_warning = if total_size >= 2_000_000_000
                   "\nWarning: This set is too large to be frozen and too large too large to transfer to Push 3 Standalone.".red
                 else
                   ''
                 end
  total_set_size = "Total set size: #{human_file_size total_size}".yellow
  <<~END_MSG
    #{p3s_tx_msg}
    #{total_set_size}#{size_warning}
    #{@track_instances.count} tracks#{all_frozen_msg}:
  END_MSG
end