Class: Dokaz::ShowcaseFormatter

Inherits:
Formatter show all
Defined in:
lib/dokaz/formatters.rb

Instance Method Summary collapse

Methods inherited from Formatter

#finalize

Instance Method Details

#finish_block(block) ⇒ Object



93
94
95
# File 'lib/dokaz/formatters.rb', line 93

def finish_block(block)
  puts "\n\n"
end

#output(code, res, out) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/dokaz/formatters.rb', line 80

def output(code, res, out)
  puts code
  unless out.empty?
    puts comment("# Prints: \n#  " + out.split("\n").join("\n#    "))
  end
  puts comment("# => " + res.inspect.split("\n").join("\n#    "))
end

#output_err(code, e) ⇒ Object



88
89
90
91
# File 'lib/dokaz/formatters.rb', line 88

def output_err(code, e)
  puts code
  puts comment("# Throws: #{e.message} (#{e.class})")
end

#start_block(block) ⇒ Object



76
77
78
# File 'lib/dokaz/formatters.rb', line 76

def start_block(block)
  puts "#{block.caption}\n#{'=' * block.caption.size}\n\n"
end