Class: Gamefic::User::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/user/buffer.rb

Overview

A simple buffer class for collecting and returning data received from plots.

Instance Method Summary collapse

Constructor Details

#initializeBuffer

Returns a new instance of Buffer.



6
7
8
# File 'lib/gamefic/user/buffer.rb', line 6

def initialize
  @data = ''
end

Instance Method Details

#flushString

Get the current data and clear the buffer.

Returns:



25
26
27
28
29
# File 'lib/gamefic/user/buffer.rb', line 25

def flush
  tmp = @data
  @data = ''
  tmp
end

#peekString

Read the current buffer without clearing it.

Returns:



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 message
  @data += message
end