Class: PrettyPrint::Breakable
Overview
The Breakable class is used for breaking up object information
This class is intended for internal use of the PrettyPrint buffers.
Instance Attribute Summary collapse
- 
  
    
      #indent  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The number of spaces to indent. 
- 
  
    
      #obj  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Holds the separator String. 
- 
  
    
      #width  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The width of +obj+ / +sep+. 
Instance Method Summary collapse
- 
  
    
      #initialize(sep, width, q)  ⇒ Breakable 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Create a new Breakable object. 
- 
  
    
      #output(out, output_width)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Render the String text of the objects that have been added to this Breakable object. 
Constructor Details
#initialize(sep, width, q) ⇒ Breakable
Create a new Breakable object.
Arguments:
- +sep+ String of the separator
- +width+ Fixnum width of the +sep+
- +q+ parent PrettyPrint object, to base from
| 345 346 347 348 349 350 351 352 | # File 'opal/stdlib/prettyprint.rb', line 345 def initialize(sep, width, q) @obj = sep @width = width @pp = q @indent = q.indent @group = q.current_group @group.breakables.push self end | 
Instance Attribute Details
#indent ⇒ Object (readonly)
The number of spaces to indent.
This is inferred from +q+ within PrettyPrint, passed in ::new
| 365 366 367 | # File 'opal/stdlib/prettyprint.rb', line 365 def indent @indent end | 
#obj ⇒ Object (readonly)
Holds the separator String
The +sep+ argument from ::new
| 357 358 359 | # File 'opal/stdlib/prettyprint.rb', line 357 def obj @obj end | 
#width ⇒ Object (readonly)
The width of +obj+ / +sep+
| 360 361 362 | # File 'opal/stdlib/prettyprint.rb', line 360 def width @width end | 
Instance Method Details
#output(out, output_width) ⇒ Object
Render the String text of the objects that have been added to this Breakable object.
Output the text to +out+, and increment the width to +output_width+
| 371 372 373 374 375 376 377 378 379 380 381 382 | # File 'opal/stdlib/prettyprint.rb', line 371 def output(out, output_width) @group.breakables.shift if @group.break? out << @pp.newline out << @pp.genspace.call(@indent) @indent else @pp.group_queue.delete @group if @group.breakables.empty? out << @obj output_width + @width end end |