Class: WebUnit::MemWriter
Instance Method Summary
collapse
Methods inherited from NullWriter
#flush, #new_alignment, #new_font, #new_margin, #new_spacing, #new_styles, #send_label_data
Constructor Details
Returns a new instance of MemWriter.
391
392
393
394
395
396
|
# File 'lib/webunit/response.rb', line 391
def initialize
@body = ''
@maxcol = 72
super()
reset
end
|
Instance Method Details
398
399
400
401
|
# File 'lib/webunit/response.rb', line 398
def reset
@col = 0
@atbreak = false
end
|
#send_flowing_data(data) ⇒ Object
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
# File 'lib/webunit/response.rb', line 439
def send_flowing_data(data)
return if not data
atbreak = (@atbreak || (/^\s/ =~ data))
col = @col
maxcol = @maxcol
for word in data.split
if atbreak
if col + word.length >= maxcol
@body << ("\n")
col = 0
else
@body << (' ')
col = col + 1
end
end
@body << (word)
col = col + word.length
atbreak = true
end
@col = col
@atbreak = (/\s$/ =~ data)
end
|
#send_hor_rule ⇒ Object
419
420
421
422
423
424
425
|
# File 'lib/webunit/response.rb', line 419
def send_hor_rule @body << ("\n")
@body << ('-'*@maxcol)
@body << ("\n")
@col = 0
@atbreak = false
end
|
#send_line_break ⇒ Object
413
414
415
416
417
|
# File 'lib/webunit/response.rb', line 413
def send_line_break
@body << ("\n")
@col = 0
@atbreak = false
end
|
#send_literal_data(data) ⇒ Object
427
428
429
430
431
432
433
434
435
436
437
|
# File 'lib/webunit/response.rb', line 427
def send_literal_data(data)
@body << (data)
i = data.rindex("\n")
if i
@col = 0
data = data[i+1..-1]
@col = @col + data.length
@atbreak = false
end
end
|
#send_paragraph(blankline) ⇒ Object
407
408
409
410
411
|
# File 'lib/webunit/response.rb', line 407
def send_paragraph(blankline)
@body << ("\n" + "\n"*blankline)
@col = 0
@atbreak = false
end
|
403
404
405
|
# File 'lib/webunit/response.rb', line 403
def to_s
@body.squeeze( "\n" )
end
|