class Multisync::List
Attributes
catalog[R]
Given catalog
tasks[R]
Tasks
Public Class Methods
new(catalog)
click to toggle source
# File lib/multisync/list.rb, line 12 def initialize catalog @catalog = catalog @tasks = [] end
Public Instance Methods
description(subject)
click to toggle source
# File lib/multisync/list.rb, line 36 def description subject desc = [subject.source_description, subject.destination_description] desc.any?(&:empty?) ? [] : [desc.first, ['--> ', desc.last].join] end
table()
click to toggle source
# File lib/multisync/list.rb, line 22 def table Terminal::Table.new(rows: tasks, style: table_style) end
table_style()
click to toggle source
# File lib/multisync/list.rb, line 41 def table_style { border_top: false, border_bottom: false, border_x: '–', border_y: '', border_i: '', padding_left: 0, padding_right: 3 } end
to_s()
click to toggle source
# File lib/multisync/list.rb, line 17 def to_s catalog.traverse self table.to_s end
visit(subject, level)
click to toggle source
# File lib/multisync/list.rb, line 26 def visit subject, level if level > 0 tab = ''.ljust(2*(level-1), ' ') default = subject.default? ? ' *' : '' name = "#{tab}#{subject.name}#{default}" tasks << [name, *description(subject).map(&:faint)] # puts "#{name.ljust(32, ' ')}#{description(subject)}" end end