Module: CodeStringFormatter

Defined in:
lib/asker/formatter/code_string_formatter.rb

Overview

Define methods to trasnforme Code object into String

Class Method Summary collapse

Class Method Details

.to_s(code) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/asker/formatter/code_string_formatter.rb', line 8

def self.to_s(code)
  t = Terminal::Table.new
  msg = Rainbow(code.filename).white.bg(:blue).bright
  t.add_row [Rainbow("Code").bright, msg]
  t.add_row [Rainbow("Type").blue, code.type.to_s]
  t.add_row [Rainbow("Lines").blue, code.lines_to_s(code.lines)]
  "#{t}\n"
end