Class: DEBUGGER__::LimitedPP

Inherits:
Object
  • Object
show all
Defined in:
lib/debug/session.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max) ⇒ LimitedPP

Returns a new instance of LimitedPP.



2345
2346
2347
2348
2349
# File 'lib/debug/session.rb', line 2345

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

Instance Attribute Details

#bufObject (readonly)

Returns the value of attribute buf.



2343
2344
2345
# File 'lib/debug/session.rb', line 2343

def buf
  @buf
end

Class Method Details

.pp(obj, max = 80) ⇒ Object



2335
2336
2337
2338
2339
2340
2341
# File 'lib/debug/session.rb', line 2335

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

Instance Method Details

#<<(other) ⇒ Object



2351
2352
2353
2354
2355
2356
2357
2358
# File 'lib/debug/session.rb', line 2351

def <<(other)
  @buf << other

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