Class: RShade::Formatter::Stack::String

Inherits:
Object
  • Object
show all
Defined in:
lib/rshade/formatter/stack/string.rb

Direct Known Subclasses

Stdout

Constant Summary collapse

ROOT_SEP =
"---\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(colorize: true) ⇒ String



11
12
13
# File 'lib/rshade/formatter/stack/string.rb', line 11

def initialize(colorize: true)
  @colorize = colorize
end

Instance Attribute Details

#colorizeObject (readonly)

Returns the value of attribute colorize.



7
8
9
# File 'lib/rshade/formatter/stack/string.rb', line 7

def colorize
  @colorize
end

Instance Method Details

#call(stack_frames, variable_serializer: nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rshade/formatter/stack/string.rb', line 16

def call(stack_frames, variable_serializer: nil)
  buffer = StringIO.new
  stack_frames.each_with_index do |frame, idx|
    if idx.zero?
      buffer << ROOT_SEP
      next
    end
    next unless frame

    buffer.write line(idx, frame, idx)
  end
  buffer.string
end