Class: Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/aidir/formatter.rb

Instance Method Summary collapse

Instance Method Details

#caption(title) ⇒ Object



3
4
5
# File 'lib/aidir/formatter.rb', line 3

def caption(title)
  "\n--- #{colors[:cyan]}#{title}#{color_end} ---\n"
end

#deleted_method_row(method) ⇒ Object



22
23
24
# File 'lib/aidir/formatter.rb', line 22

def deleted_method_row(method)
  sprintf(format[:header], 'deleted', '-', method)
end

#file_row(metric, info) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/aidir/formatter.rb', line 26

def file_row(metric, info)
  filename = info[:file]
  delta = info[:delta]
  if metric == 'flog total'
    current = preformat_file_total(info[:current])
  elsif metric == 'flog/method average'
    current = preformat_file_avg(info[:current])
  end
  sprintf(format[:method_row], preformat_delta(delta), current, filename)
end

#method_row(method, info) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/aidir/formatter.rb', line 11

def method_row(method, info)
  return deleted_method_row(method) if info[:flag] == :deleted
  current = info[:current]
  if info[:flag] == :new
    contents = preformat_flag(info[:flag])
  else
    contents = preformat_delta(info[:delta])
  end
  sprintf(format[:method_row], contents, preformat_current(current), method)
end

#table_header(col1, col2, col3) ⇒ Object



7
8
9
# File 'lib/aidir/formatter.rb', line 7

def table_header(col1, col2, col3)
  sprintf(format[:header], col1, col2, col3)
end