Class: KiMiddleman::TransformationsRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/ki_middleman/transformations_renderer.rb

Class Method Summary collapse

Class Method Details

.render(transformations) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ki_middleman/transformations_renderer.rb', line 5

def self.render(transformations)
  output = []
  longest_origin_format_length = transformations.keys.map(&:length).max
  transformations.each do |origin_format, destination_format_array|
    last_index = destination_format_array.length - 1
    destination_format_array.each_with_index do |destination_format, index|
      output <<
        "%-#{longest_origin_format_length}s %s %s" %
        [render_origin_format(origin_format, index),
         render_arrows(index, last_index),
         destination_format]
    end
  end
  output.map {|o| o + "\n"}.join
end

.render_arrows(index, last_index) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ki_middleman/transformations_renderer.rb', line 21

def self.render_arrows(index, last_index)
  return "--->" if last_index == 0
  case index
  when 0
    "-+->"
  when last_index
    " \\->"
  else
    " |->"
  end
end