Class: Kojak::Output

Inherits:
String
  • Object
show all
Defined in:
lib/kojak/output.rb

Overview

Internal: Pretty output string from given caller information.

Instance Method Summary collapse

Constructor Details

#initialize(caller) ⇒ Output

Public: Constructor. Generates output from given caller.



5
6
7
8
# File 'lib/kojak/output.rb', line 5

def initialize(caller)
  @c = caller
  super("\n" + all.flatten.compact.join("\n") + "\n")
end

Instance Method Details

#allObject



10
11
12
13
14
15
# File 'lib/kojak/output.rb', line 10

def all
  [
    header, receiver, location, pid, realtime, arguments, 
    result, err, footer
  ]
end

#argumentsObject



37
38
39
40
41
# File 'lib/kojak/output.rb', line 37

def arguments
  args = @c[:args]
  return if !args || args.empty?
  ["--- arguments ".ljust(80, '-'), pp(args)]
end

#errObject



49
50
51
52
53
54
# 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


56
57
58
# File 'lib/kojak/output.rb', line 56

def footer
  "=" * 80
end

#headerObject



17
18
19
# File 'lib/kojak/output.rb', line 17

def header
  "=== #{@c[:name]} ".ljust(80, "=")
end

#locationObject



25
26
27
# File 'lib/kojak/output.rb', line 25

def location
  "source_location=#{@c[:location].join(":")}"
end

#pidObject



29
30
31
# File 'lib/kojak/output.rb', line 29

def pid
  "pid=#{@c[:pid]}"
end

#realtimeObject



33
34
35
# File 'lib/kojak/output.rb', line 33

def realtime
  "real_time=%.5f" % @c[:realtime]
end

#receiverObject



21
22
23
# File 'lib/kojak/output.rb', line 21

def receiver
  "receiver_class=#{@c[:receiver]}"
end

#resultObject



43
44
45
46
47
# File 'lib/kojak/output.rb', line 43

def result
  res = @c[:result]
  return if res.nil?
  ["--- result ".ljust(80, '-'), pp(res)]
end