Class: PrettyPrint::SingleLine
Instance Method Summary (collapse)
- - (Object) breakable(sep = ' ', width = nil)
- - (Boolean) first?
- - (Object) flush
- - (Object) group(indent = nil, open_obj = '', close_obj = '', open_width = nil, close_width = nil)
-
- (SingleLine) initialize(output, maxwidth = nil, newline = nil)
constructor
A new instance of SingleLine.
- - (Object) nest(indent)
- - (Object) text(obj, width = nil)
Constructor Details
- (SingleLine) initialize(output, maxwidth = nil, newline = nil)
A new instance of SingleLine
343 344 345 346 |
# File 'lib/prettyprint.rb', line 343 def initialize(output, maxwidth=nil, newline=nil) @output = output @first = [true] end |
Instance Method Details
- (Object) breakable(sep = ' ', width = nil)
352 353 354 |
# File 'lib/prettyprint.rb', line 352 def breakable(sep=' ', width=nil) @output << sep end |
- (Boolean) first?
371 372 373 374 375 |
# File 'lib/prettyprint.rb', line 371 def first? result = @first[-1] @first[-1] = false result end |
- (Object) flush
368 369 |
# File 'lib/prettyprint.rb', line 368 def flush end |
- (Object) group(indent = nil, open_obj = '', close_obj = '', open_width = nil, close_width = nil)
360 361 362 363 364 365 366 |
# File 'lib/prettyprint.rb', line 360 def group(indent=nil, open_obj='', close_obj='', open_width=nil, close_width=nil) @first.push true @output << open_obj yield @output << close_obj @first.pop end |
- (Object) nest(indent)
356 357 358 |
# File 'lib/prettyprint.rb', line 356 def nest(indent) yield end |
- (Object) text(obj, width = nil)
348 349 350 |
# File 'lib/prettyprint.rb', line 348 def text(obj, width=nil) @output << obj end |