Class: PrettyPrint::Breakable
- Inherits:
-
Object
- Object
- PrettyPrint::Breakable
- Defined in:
- lib/prettyprint.rb
Instance Attribute Summary collapse
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(sep, width, q) ⇒ Breakable
constructor
A new instance of Breakable.
- #output(out, output_width) ⇒ Object
Constructor Details
#initialize(sep, width, q) ⇒ Breakable
Returns a new instance of Breakable.
278 279 280 281 282 283 284 285 |
# File 'lib/prettyprint.rb', line 278 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)
Returns the value of attribute indent
286 287 288 |
# File 'lib/prettyprint.rb', line 286 def indent @indent end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj
286 287 288 |
# File 'lib/prettyprint.rb', line 286 def obj @obj end |
#width ⇒ Object (readonly)
Returns the value of attribute width
286 287 288 |
# File 'lib/prettyprint.rb', line 286 def width @width end |
Instance Method Details
#output(out, output_width) ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/prettyprint.rb', line 288 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 |