Class PrettyPrint::Breakable
In: lib/prettyprint.rb
Parent: Object

Methods

new   output  

Attributes

indent  [R] 
obj  [R] 
width  [R] 

Public Class methods

[Source]

     # File lib/prettyprint.rb, line 262
262:     def initialize(sep, width, q)
263:       @obj = sep
264:       @width = width
265:       @pp = q
266:       @indent = q.indent
267:       @group = q.current_group
268:       @group.breakables.push self
269:     end

Public Instance methods

[Source]

     # File lib/prettyprint.rb, line 272
272:     def output(out, output_width)
273:       @group.breakables.shift
274:       if @group.break?
275:         out << @pp.newline
276:         out << @pp.genspace.call(@indent)
277:         @indent
278:       else
279:         @pp.group_queue.delete @group if @group.breakables.empty?
280:         out << @obj
281:         output_width + @width
282:       end
283:     end

[Validate]