Class: TestBench::Session::Output::Writer
- Inherits:
-
Output::Writer
- Object
- Output::Writer
- TestBench::Session::Output::Writer
show all
- Defined in:
- lib/test_bench/session/output/writer.rb,
lib/test_bench/session/output/writer/buffer.rb,
lib/test_bench/session/output/writer/defaults.rb,
lib/test_bench/session/output/writer/substitute.rb,
lib/test_bench/session/output/writer/buffer/interactive.rb,
lib/test_bench/session/output/writer/buffer/interactive/viewport.rb
Defined Under Namespace
Modules: Buffer, Defaults, Substitute
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#alternate_device ⇒ Object
7
8
9
|
# File 'lib/test_bench/session/output/writer.rb', line 7
def alternate_device
@alternate_device ||= TestBench::Output::Device::Substitute.build
end
|
#indentation_depth ⇒ Object
12
13
14
|
# File 'lib/test_bench/session/output/writer.rb', line 12
def indentation_depth
@indentation_depth ||= 0
end
|
#peer ⇒ Object
Returns the value of attribute peer.
5
6
7
|
# File 'lib/test_bench/session/output/writer.rb', line 5
def peer
@peer
end
|
Class Method Details
.follow(previous_writer) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/test_bench/session/output/writer.rb', line 25
def self.follow(previous_writer)
device = previous_writer
alternate_device = previous_writer.peer
alternate_device ||= TestBench::Output::Device::Null.build
previous_digest = previous_writer.digest
digest = previous_digest.clone
writer = new
writer.sync = false
writer.device = device
writer.alternate_device = alternate_device
writer.styling_policy = previous_writer.styling_policy
writer.digest = digest
writer.sequence = previous_writer.sequence
writer.column_sequence = previous_writer.column_sequence
writer.indentation_depth = previous_writer.indentation_depth
writer.digest = previous_writer.digest.clone
writer
end
|
Instance Method Details
#branch ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/test_bench/session/output/writer.rb', line 47
def branch
alternate = self.class.follow(self)
primary = self.class.follow(self)
primary.peer = alternate
return primary, alternate
end
|
17
18
19
20
21
22
23
|
# File 'lib/test_bench/session/output/writer.rb', line 17
def configure
device = self.device
self.alternate_device = TestBench::Output::Device::Null.build
Buffer.configure(self, device:)
end
|
#decrease_indentation ⇒ Object
Also known as:
deindent!
76
77
78
|
# File 'lib/test_bench/session/output/writer.rb', line 76
def decrease_indentation
self.indentation_depth -= 1
end
|
#flush ⇒ Object
62
63
64
|
# File 'lib/test_bench/session/output/writer.rb', line 62
def flush
buffer.flush(device, alternate_device)
end
|
#follows?(other_writer) ⇒ Boolean
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/test_bench/session/output/writer.rb', line 81
def follows?(other_writer)
if sequence < other_writer.sequence
false
elsif device == other_writer
true
elsif device == other_writer.peer
true
else
false
end
end
|
#increase_indentation ⇒ Object
Also known as:
indent!
71
72
73
|
# File 'lib/test_bench/session/output/writer.rb', line 71
def increase_indentation
self.indentation_depth += 1
end
|
#indent ⇒ Object
56
57
58
59
60
|
# File 'lib/test_bench/session/output/writer.rb', line 56
def indent
indentation = ' ' * indentation_depth
print(indentation)
end
|
#write!(data) ⇒ Object
66
67
68
69
|
# File 'lib/test_bench/session/output/writer.rb', line 66
def write!(data)
device.write(data)
alternate_device.write(data)
end
|