Class: RASN1::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/rasn1/tracer.rb

Constant Summary collapse

TRACED_CLASSES =
[Types::Any, Types::Choice, Types::Sequence, Types::SequenceOf, Types::Base].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Tracer

Returns a new instance of Tracer.

Parameters:

  • io (IO)


14
15
16
17
# File 'lib/rasn1/tracer.rb', line 14

def initialize(io)
  @io = io
  @tracing_level = 0
end

Instance Attribute Details

#ioIO (readonly)

Returns:

  • (IO)


7
8
9
# File 'lib/rasn1/tracer.rb', line 7

def io
  @io
end

#tracing_levelInteger

Returns:

  • (Integer)


9
10
11
# File 'lib/rasn1/tracer.rb', line 9

def tracing_level
  @tracing_level
end

Instance Method Details

#indent(level = nil) ⇒ String

Return identation for given level. If nil, use #tracing_level.

Parameters:

  • level (Integer, nil) (defaults to: nil)

Returns:

  • (String)


29
30
31
32
# File 'lib/rasn1/tracer.rb', line 29

def indent(level=nil)
  level ||= @tracing_level
  '  ' * level
end

#trace(msg) ⇒ void

This method returns an undefined value.

Puts msg onto #io.

Parameters:

  • msg (String)


22
23
24
# File 'lib/rasn1/tracer.rb', line 22

def trace(msg)
  @io.puts(indent << msg)
end