Module: MindmeisterApi::Printer

Includes:
KLog::Logging
Defined in:
lib/mindmeister_api/printer/node_printer.rb

Overview

Include the Printer namespace to have access to console printers

Instance Method Summary collapse

Instance Method Details



9
10
11
12
13
14
# File 'lib/mindmeister_api/printer/node_printer.rb', line 9

def print_mindmap(mindmap, take: nil)
  list = NodeEnumerator.new(mindmap).list
  list = list.take(take) if take

  print_nodes_as_table(list)
end

rubocop:disable Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mindmeister_api/printer/node_printer.rb', line 17

def print_nodes_as_table(nodes)
  log.section_heading 'Mindmap'

  tp nodes,
     :id,
     :level,
     { title: { width: 50, display_method: ->(row) { "#{' ' * ((row.level - 1) * 2)}#{row.title.gsub("\r", ' ')}" } } },
     :rank,
     { pos: { display_method: ->(row) { row.pos.nil? ? '' : row.pos.reject(&:nil?).join(',').to_s } } },
     :floating,
     { icon: { display_method: ->(row) { row.icon.nil? ? '' : row.icon.reject(&:nil?).join(',').to_s } } }
  #  :style,
  #  :note,
  #  { link: { width: 30 } },
  #  :task,
  #  :attachments,
  #  :image,
  #  :boundary,
  #  :video
end