Class: FormatCode2Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/asker/exporter/doc/format_code2doc.rb

Instance Method Summary collapse

Instance Method Details

#call(code) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/asker/exporter/doc/format_code2doc.rb', line 2

def call(code)
  out = ""
  title = "#{code.filename} (#{code.type})"
  out << ("-" * title.size + "\n")
  out << "#{title}\n"
  if code.features.size.positive?
    out << "* features: #{code.features.join(", ")}"
  end
  out << "\n"
  code.lines.each_with_index do |line, index|
    out << "#{index} | #{line}\n"
  end
  out << "\n"
  out
end