Class: TestBench::Output::Writer::Buffer
- Inherits:
-
Object
- Object
- TestBench::Output::Writer::Buffer
- Defined in:
- lib/test_bench/output/writer/buffer.rb,
lib/test_bench/output/writer/buffer/console.rb
Defined Under Namespace
Classes: Console
Instance Attribute Summary collapse
- #contents ⇒ Object
-
#limit ⇒ Object
Returns the value of attribute limit.
Instance Method Summary collapse
Instance Attribute Details
#contents ⇒ Object
7 8 9 |
# File 'lib/test_bench/output/writer/buffer.rb', line 7 def contents @contents ||= String.new end |
#limit ⇒ Object
Returns the value of attribute limit.
5 6 7 |
# File 'lib/test_bench/output/writer/buffer.rb', line 5 def limit @limit end |
Instance Method Details
#flush(device = nil, alternate_device = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/test_bench/output/writer/buffer.rb', line 34 def flush(device=nil, alternate_device=nil) if not device.nil? device.write(contents) end if not alternate_device.nil? alternate_device.write(contents) end contents.clear end |
#limit? ⇒ Boolean
30 31 32 |
# File 'lib/test_bench/output/writer/buffer.rb', line 30 def limit? !limit.nil? end |
#receive(data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/test_bench/output/writer/buffer.rb', line 12 def receive(data) bytes = data.bytesize if not limit.nil? final_size = contents.bytesize + data.bytesize if final_size > limit bytes = limit - contents.bytesize end end data = data[0...bytes] contents << data bytes end |