Method: PrettyPrint#text

Defined in:
lib/extensions/mspec/mspec/pp.rb

#text(obj, width = obj.length) ⇒ Object

This adds obj as a text of width columns in width.

If width is not specified, obj.length is used.



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/extensions/mspec/mspec/pp.rb', line 187

def text(obj, width=obj.length)
  if @buffer.empty?
    @output << obj
    @output_width += width
  else
    text = @buffer.last
    unless Text === text
      text = Text.new
      @buffer << text
    end
    text.add(obj, width)
    @buffer_width += width
    break_outmost_groups
  end
end