Class: Gamefic::User::Buffer
- Inherits:
-
Object
- Object
- Gamefic::User::Buffer
- Defined in:
- lib/gamefic/user/buffer.rb
Overview
A simple buffer class for collecting and returning data received from plots.
Instance Method Summary collapse
-
#flush ⇒ String
Get the current data and clear the buffer.
-
#initialize ⇒ Buffer
constructor
A new instance of Buffer.
-
#peek ⇒ String
Read the current buffer without clearing it.
-
#send(message) ⇒ Object
Append a message to the buffer.
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
6 7 8 |
# File 'lib/gamefic/user/buffer.rb', line 6 def initialize @data = '' end |
Instance Method Details
#flush ⇒ String
Get the current data and clear the buffer.
25 26 27 28 29 |
# File 'lib/gamefic/user/buffer.rb', line 25 def flush tmp = @data @data = '' tmp end |
#peek ⇒ String
Read the current buffer without clearing it.
18 19 20 |
# File 'lib/gamefic/user/buffer.rb', line 18 def peek @data end |
#send(message) ⇒ Object
Append a message to the buffer.
11 12 13 |
# File 'lib/gamefic/user/buffer.rb', line 11 def send @data += end |