Class: PrettyPrint::SingleLine

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/mspec/mspec/pp.rb

Direct Known Subclasses

PP::SingleLine

Instance Method Summary collapse

Constructor Details

#initialize(output, maxwidth = nil, newline = nil) ⇒ SingleLine

Returns a new instance of SingleLine.



388
389
390
391
# File 'lib/extensions/mspec/mspec/pp.rb', line 388

def initialize(output, maxwidth=nil, newline=nil)
  @output = output
  @first = [true]
end

Instance Method Details

#breakable(sep = ' ', width = nil) ⇒ Object



397
398
399
# File 'lib/extensions/mspec/mspec/pp.rb', line 397

def breakable(sep=' ', width=nil)
  @output << sep
end

#first?Boolean

Returns:

  • (Boolean)


416
417
418
419
420
# File 'lib/extensions/mspec/mspec/pp.rb', line 416

def first?
  result = @first[-1]
  @first[-1] = false
  result
end

#flushObject



413
414
# File 'lib/extensions/mspec/mspec/pp.rb', line 413

def flush
end

#group(indent = nil, open_obj = '', close_obj = '', open_width = nil, close_width = nil) ⇒ Object



405
406
407
408
409
410
411
# File 'lib/extensions/mspec/mspec/pp.rb', line 405

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



401
402
403
# File 'lib/extensions/mspec/mspec/pp.rb', line 401

def nest(indent)
  yield
end

#text(obj, width = nil) ⇒ Object



393
394
395
# File 'lib/extensions/mspec/mspec/pp.rb', line 393

def text(obj, width=nil)
  @output << obj
end