Class: TraceTree::PointsMarkdownTable
- Inherits:
-
Object
- Object
- TraceTree::PointsMarkdownTable
- Defined in:
- lib/trace_tree/points_markdown_table.rb
Constant Summary collapse
- HEADERS =
[:event, :defined_class, :method_id, :frame_env, :path, :lineno, :thread, :return_value]
- COL_SEPERATOR =
'|'
- HEADER_BOTTOM =
'-'
- NEWLINE =
"\n"
- RETURN =
/return/
- LT_RAW =
/</
- LT_ESC =
'<'
- GT_RAW =
/>/
- GT_ESC =
'>'
- COL_RAW =
'|'
- COL_ESC =
'|'
Instance Method Summary collapse
- #end_row ⇒ Object
- #generate_headers ⇒ Object
- #generate_rows ⇒ Object
-
#initialize(points) ⇒ PointsMarkdownTable
constructor
A new instance of PointsMarkdownTable.
- #point_to_row(info) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(points) ⇒ PointsMarkdownTable
Returns a new instance of PointsMarkdownTable.
16 17 18 |
# File 'lib/trace_tree/points_markdown_table.rb', line 16 def initialize(points) @points = points end |
Instance Method Details
#end_row ⇒ Object
49 50 51 |
# File 'lib/trace_tree/points_markdown_table.rb', line 49 def end_row @buffer << COL_SEPERATOR << NEWLINE end |
#generate_headers ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/trace_tree/points_markdown_table.rb', line 27 def generate_headers HEADERS.each{ |h| @buffer << COL_SEPERATOR << h } @buffer << COL_SEPERATOR @buffer << NEWLINE HEADERS.each{ |h| @buffer << COL_SEPERATOR << HEADER_BOTTOM } end_row end |
#generate_rows ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/trace_tree/points_markdown_table.rb', line 35 def generate_rows @points.each do |point| point_to_row(point.event) point_to_row(point.defined_class) point_to_row(point.method_id) point_to_row(point.thread? ? nil : point.frame_env) point_to_row(point.path) point_to_row(point.lineno) point_to_row(point.thread) point_to_row(point.event =~ RETURN ? point.return_value : nil) end_row end end |
#point_to_row(info) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/trace_tree/points_markdown_table.rb', line 53 def point_to_row(info) info = info.to_s.gsub(LT_RAW, LT_ESC) info.gsub!(GT_RAW, GT_ESC) info.gsub!(COL_RAW, COL_ESC) @buffer << COL_SEPERATOR << info end |
#to_s ⇒ Object
20 21 22 23 24 25 |
# File 'lib/trace_tree/points_markdown_table.rb', line 20 def to_s @buffer = [] generate_headers generate_rows @buffer.join end |