Class: Multisync::Catalog::List

Inherits:
Object
  • Object
show all
Defined in:
lib/multisync/catalog/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeList

Returns a new instance of List.



6
7
8
# File 'lib/multisync/catalog/list.rb', line 6

def initialize
  @result = []
end

Instance Attribute Details

#resultObject (readonly)

result



4
5
6
# File 'lib/multisync/catalog/list.rb', line 4

def result
  @result
end

Instance Method Details

#description(subject) ⇒ Object



20
21
22
23
# File 'lib/multisync/catalog/list.rb', line 20

def description subject
  desc = [subject.source_description, subject.destination_description]
  desc.any?(&:empty?) ? [] : [desc.first, ['--> ', desc.last].join]
end

#visit(subject, level) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/multisync/catalog/list.rb', line 10

def visit subject, level
  if level > 0
    tab = ''.ljust(2*(level-1), ' ')
    default = subject.default? ? ' *' : ''
    name = "#{tab}#{subject.name}#{default}"
    @result << [name, *description(subject)]
    # puts "#{name.ljust(32, ' ')}#{description(subject)}"
  end
end