Class: Godwit::Buffer
- Inherits:
-
Object
- Object
- Godwit::Buffer
- Defined in:
- lib/godwit/buffer.rb
Overview
This class is used to buffer output. It’s used to help out with view switching in the console.
Class Method Summary collapse
-
.buffer ⇒ Object
Returns the buffer.
-
.buffer=(string) ⇒ Object
Sets the buffer.
-
.clear ⇒ Object
Clears the buffer.
-
.print(string) ⇒ Object
Outputs text with Kernel#print and stores it in the buffer.
-
.puts(string) ⇒ Object
Outputs text with Kernel#puts and stores it in the buffer.
Class Method Details
.buffer ⇒ Object
Returns the buffer.
11 12 13 14 |
# File 'lib/godwit/buffer.rb', line 11 def buffer @buffer ||= "" @buffer end |
.buffer=(string) ⇒ Object
Sets the buffer
18 19 20 21 |
# File 'lib/godwit/buffer.rb', line 18 def buffer=(string) @buffer ||= "" @buffer = string end |
.clear ⇒ Object
Clears the buffer.
39 40 41 |
# File 'lib/godwit/buffer.rb', line 39 def clear self.buffer = "" end |
.print(string) ⇒ Object
Outputs text with Kernel#print and stores it in the buffer.
25 26 27 28 |
# File 'lib/godwit/buffer.rb', line 25 def print(string) self.buffer += string Kernel.print string end |
.puts(string) ⇒ Object
Outputs text with Kernel#puts and stores it in the buffer.
32 33 34 35 |
# File 'lib/godwit/buffer.rb', line 32 def puts(string) self.buffer += (string + "\n") Kernel.puts string end |