Class: PrettyPrint::Text

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeText

Returns a new instance of Text.



287
288
289
290
# File 'lib/extensions/mspec/mspec/pp.rb', line 287

def initialize
  @objs = []
  @width = 0
end

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width.



291
292
293
# File 'lib/extensions/mspec/mspec/pp.rb', line 291

def width
  @width
end

Instance Method Details

#add(obj, width) ⇒ Object



298
299
300
301
# File 'lib/extensions/mspec/mspec/pp.rb', line 298

def add(obj, width)
  @objs << obj
  @width += width
end

#output(out, output_width) ⇒ Object



293
294
295
296
# File 'lib/extensions/mspec/mspec/pp.rb', line 293

def output(out, output_width)
  @objs.each {|obj| out << obj}
  output_width + @width
end