class Kojak::Output
Internal: Pretty output string from given caller information.
Public Class Methods
new(caller)
click to toggle source
Public: Constructor. Generates output from given caller.
Calls superclass method
# File lib/kojak/output.rb, line 5 def initialize(caller) @c = caller super("\n" + all.flatten.compact.join("\n") + "\n") end
Public Instance Methods
all()
click to toggle source
# File lib/kojak/output.rb, line 10 def all [ header, receiver, location, pid, realtime, arguments, result, err, footer ] end
arguments()
click to toggle source
# File lib/kojak/output.rb, line 37 def arguments args = @c[:args] return if !args || args.empty? ["--- arguments ".ljust(80, '-'), pp(args)] end
err()
click to toggle source
# File lib/kojak/output.rb, line 49 def err err = @c[:err] return if err.nil? errname = err.class.name + ": " + err.to_s ["--- exception ".ljust(80, '-'), errname] end
header()
click to toggle source
# File lib/kojak/output.rb, line 17 def header "=== #{@c[:name]} ".ljust(80, "=") end
location()
click to toggle source
# File lib/kojak/output.rb, line 25 def location "source_location=#{@c[:location].join(":")}" end
pid()
click to toggle source
# File lib/kojak/output.rb, line 29 def pid "pid=#{@c[:pid]}" end
realtime()
click to toggle source
# File lib/kojak/output.rb, line 33 def realtime "real_time=%.5f" % @c[:realtime] end
receiver()
click to toggle source
# File lib/kojak/output.rb, line 21 def receiver "receiver_class=#{@c[:receiver]}" end
result()
click to toggle source
# File lib/kojak/output.rb, line 43 def result res = @c[:result] return if res.nil? ["--- result ".ljust(80, '-'), pp(res)] end
Protected Instance Methods
pp(x)
click to toggle source
# File lib/kojak/output.rb, line 62 def pp(x) JSON.pretty_generate(x) rescue x.inspect end