CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/ui/text/output/buffer.rb
Views: 11704
1
# -*- coding: binary -*-
2
3
module Rex
4
module Ui
5
module Text
6
7
###
8
#
9
# This class implements output against a buffer.
10
#
11
###
12
class Output::Buffer < Rex::Ui::Text::Output
13
14
#
15
# Initializes an output buffer.
16
#
17
def initialize
18
self.buf = ''
19
end
20
21
def supports_color?
22
false
23
end
24
25
#
26
# Appends the supplied message to the output buffer.
27
#
28
def print_raw(msg = '')
29
self.buf += msg || ''
30
31
msg
32
end
33
34
35
#
36
# Read everything out of the buffer and reset it
37
#
38
def dump_buffer
39
self.buf ||= ''
40
buffer = self.buf.dup
41
reset()
42
buffer
43
end
44
45
#
46
# Reset the buffer to an empty string.
47
#
48
def reset
49
self.buf = ''
50
end
51
52
#
53
# The underlying buffer state.
54
#
55
attr_accessor :buf
56
57
end
58
59
end
60
end
61
end
62
63