Class: Kojak::Output
- Inherits:
-
String
- Object
- String
- Kojak::Output
- Defined in:
- lib/kojak/output.rb
Overview
Internal: Pretty output string from given caller information.
Instance Method Summary collapse
- #all ⇒ Object
- #arguments ⇒ Object
- #err ⇒ Object
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(caller) ⇒ Output
constructor
Public: Constructor.
- #location ⇒ Object
- #pid ⇒ Object
- #realtime ⇒ Object
- #receiver ⇒ Object
- #result ⇒ Object
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
#all ⇒ Object
10 11 12 13 14 15 |
# File 'lib/kojak/output.rb', line 10 def all [ header, receiver, location, pid, realtime, arguments, result, err, ] end |
#arguments ⇒ Object
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 |
#err ⇒ Object
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 |
#footer ⇒ Object
56 57 58 |
# File 'lib/kojak/output.rb', line 56 def "=" * 80 end |
#header ⇒ Object
17 18 19 |
# File 'lib/kojak/output.rb', line 17 def header "=== #{@c[:name]} ".ljust(80, "=") end |
#location ⇒ Object
25 26 27 |
# File 'lib/kojak/output.rb', line 25 def location "source_location=#{@c[:location].join(":")}" end |
#pid ⇒ Object
29 30 31 |
# File 'lib/kojak/output.rb', line 29 def pid "pid=#{@c[:pid]}" end |
#realtime ⇒ Object
33 34 35 |
# File 'lib/kojak/output.rb', line 33 def realtime "real_time=%.5f" % @c[:realtime] end |
#receiver ⇒ Object
21 22 23 |
# File 'lib/kojak/output.rb', line 21 def receiver "receiver_class=#{@c[:receiver]}" end |
#result ⇒ Object
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 |