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