Class: Tracer::Base::LimitedPP

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max) ⇒ LimitedPP

Returns a new instance of LimitedPP.



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

def initialize(max)
  @max = max
  @cnt = 0
  @buf = String.new
end

Instance Attribute Details

#bufObject (readonly)

Returns the value of attribute buf.



27
28
29
# File 'lib/tracer/base.rb', line 27

def buf
  @buf
end

Class Method Details

.pp(obj, max) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/tracer/base.rb', line 19

def self.pp(obj, max)
  out = self.new(max)
  catch out do
    PP.singleline_pp(obj, out)
  end
  out.buf
end

Instance Method Details

#<<(other) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/tracer/base.rb', line 35

def <<(other)
  @buf << other

  if @buf.size >= @max
    @buf = @buf[0..@max] + "..."
    throw self
  end
end