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.



2300
2301
2302
2303
2304
# File 'lib/debug/session.rb', line 2300

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

Instance Attribute Details

#bufObject (readonly)

Returns the value of attribute buf.



2298
2299
2300
# File 'lib/debug/session.rb', line 2298

def buf
  @buf
end

Class Method Details

.pp(obj, max = 80) ⇒ Object



2290
2291
2292
2293
2294
2295
2296
# File 'lib/debug/session.rb', line 2290

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



2306
2307
2308
2309
2310
2311
2312
2313
# File 'lib/debug/session.rb', line 2306

def <<(other)
  @buf << other

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