Class: Gamefic::Cgi::UserStream

Inherits:
UserStream show all
Defined in:
lib/gamefic/engine/cgi.rb

Instance Method Summary collapse

Methods inherited from UserStream

#recv

Constructor Details

#initializeUserStream

Returns a new instance of UserStream.



197
198
199
200
# File 'lib/gamefic/engine/cgi.rb', line 197

def initialize
  super
  @output = ''
end

Instance Method Details

#flushObject



201
202
203
204
205
# File 'lib/gamefic/engine/cgi.rb', line 201

def flush
  buffer = "#{@output}"
  @output.clear
  buffer
end

#select(prompt) ⇒ Object



212
213
214
215
216
# File 'lib/gamefic/engine/cgi.rb', line 212

def select(prompt)
  # TODO: non-blocking read
  line = STDIN.gets
  @queue.push line
end

#send(data) ⇒ Object



206
207
208
209
210
211
# File 'lib/gamefic/engine/cgi.rb', line 206

def send(data)
  #if data.start_with?(Ansi::NEL)
  #  data = "<p>#{data[Ansi::NEL.length..-1].rstrip}</p>"
  #end
  @output = "#{@output}#{data}"
end