Class: RShade::Formatter::Trace::String
- Defined in:
- lib/rshade/formatter/trace/string.rb
Direct Known Subclasses
Constant Summary collapse
- ROOT_SEP =
"---\n"
Instance Method Summary collapse
- #call(event_store) ⇒ Object
-
#initialize(opts = {}) ⇒ String
constructor
A new instance of String.
- #line(line_idx, value, depth) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ String
Returns a new instance of String.
9 |
# File 'lib/rshade/formatter/trace/string.rb', line 9 def initialize(opts = {}); end |
Instance Method Details
#call(event_store) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rshade/formatter/trace/string.rb', line 12 def call(event_store) buffer = StringIO.new event_store.each_with_index do |node, idx| depth = node.level event = node.value if depth == 1 buffer << ROOT_SEP next end next unless event buffer.write line(idx, event, node.vlevel) end buffer.string end |
#line(line_idx, value, depth) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rshade/formatter/trace/string.rb', line 28 def line(line_idx, value, depth) vars = value.vars returned_value = value.return_value || {} returned_str = "#{returned_value[:type]} #{returned_value[:value]}" returned = ColorizedString["=> |#{returned_str}|"].colorize(:magenta) class_method = ColorizedString["#{value.klass}##{value.method_name}"].colorize(:green) full_path = ColorizedString["#{value.path}:#{value.lineno}"].colorize(:blue) line_idx = ColorizedString["[#{line_idx}] "].colorize(:red) var_str = vars.map do |_, val| var_name = val[:name] var_value = val[:value] var_type = val[:type] "#{var_type} #{var_name} => (#{var_value})" end.join(', ') "#{' ' * depth}#{line_idx}#{class_method}(#{var_str}) #{returned} -> #{full_path}\n" end |