Class: Twin::Program
- Inherits:
-
Struct
- Object
- Struct
- Twin::Program
- 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
-
#jobs ⇒ Object
Returns the value of attribute jobs.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #active_jobs ⇒ Object
- #description ⇒ Object
- #label ⇒ Object
- #newest_source_mtime ⇒ Object
- #newest_target_mtime ⇒ Object
-
#status ⇒ Object
Aggregate status across jobs — worst first.
- #sync_file ⇒ Object
Instance Attribute Details
#jobs ⇒ Object
Returns the value of attribute jobs
56 57 58 |
# File 'lib/twin/scanner.rb', line 56 def jobs @jobs end |
#name ⇒ Object
Returns the value of attribute name
56 57 58 |
# File 'lib/twin/scanner.rb', line 56 def name @name end |
Instance Method Details
#active_jobs ⇒ Object
71 |
# File 'lib/twin/scanner.rb', line 71 def active_jobs = jobs.select { |j| j.active == 1 } |
#description ⇒ Object
60 61 62 |
# File 'lib/twin/scanner.rb', line 60 def description jobs.map(&:description).reject(&:empty?).uniq.join(" / ") end |
#label ⇒ Object
58 |
# File 'lib/twin/scanner.rb', line 58 def label = jobs.first&.label |
#newest_source_mtime ⇒ Object
73 |
# File 'lib/twin/scanner.rb', line 73 def newest_source_mtime = jobs.map(&:source_mtime).compact.max |
#newest_target_mtime ⇒ Object
74 |
# File 'lib/twin/scanner.rb', line 74 def newest_target_mtime = jobs.map(&:target_mtime).compact.max |
#status ⇒ Object
Aggregate status across jobs — worst first.
65 66 67 68 69 |
# File 'lib/twin/scanner.rb', line 65 def status states = jobs.map(&:status) %i[unreachable both_missing missing_source missing_target target_newer source_newer unverified disabled in_sync] .find { |s| states.include?(s) } || :in_sync end |
#sync_file ⇒ Object
57 |
# File 'lib/twin/scanner.rb', line 57 def sync_file = jobs.first&.sync_file |