Class: Twin::Program

Inherits:
Struct
  • Object
show all
Defined in:
lib/twin/scanner.rb

Overview

A logical group of Jobs sharing a Program name (e.g. "Matterbase" can have multiple paths). Selection unit in the picker.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#jobsObject

Returns the value of attribute jobs

Returns:

  • (Object)

    the current value of jobs



38
39
40
# File 'lib/twin/scanner.rb', line 38

def jobs
  @jobs
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



38
39
40
# File 'lib/twin/scanner.rb', line 38

def name
  @name
end

Instance Method Details

#active_jobsObject



53
# File 'lib/twin/scanner.rb', line 53

def active_jobs = jobs.select { |j| j.active == 1 }

#descriptionObject



42
43
44
# File 'lib/twin/scanner.rb', line 42

def description
  jobs.map(&:description).reject(&:empty?).uniq.join(" / ")
end

#labelObject



40
# File 'lib/twin/scanner.rb', line 40

def label     = jobs.first&.label

#newest_source_mtimeObject



55
# File 'lib/twin/scanner.rb', line 55

def newest_source_mtime = jobs.map(&:source_mtime).compact.max

#newest_target_mtimeObject



56
# File 'lib/twin/scanner.rb', line 56

def newest_target_mtime = jobs.map(&:target_mtime).compact.max

#statusObject

Aggregate status across jobs — worst first.



47
48
49
50
51
# File 'lib/twin/scanner.rb', line 47

def status
  states = jobs.map(&:status)
  %i[unreachable both_missing missing_source missing_target target_newer source_newer disabled in_sync]
    .find { |s| states.include?(s) } || :in_sync
end

#sync_fileObject



39
# File 'lib/twin/scanner.rb', line 39

def sync_file = jobs.first&.sync_file