Class: Gamefic::UserStream
- Inherits:
-
Object
- Object
- Gamefic::UserStream
show all
- Defined in:
- lib/gamefic/engine.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of UserStream.
64
65
66
67
|
# File 'lib/gamefic/engine.rb', line 64
def initialize
@queue = Array.new
@buffer = ''
end
|
Instance Method Details
#flush ⇒ Object
68
69
70
71
72
73
|
# File 'lib/gamefic/engine.rb', line 68
def flush
tmp = @buffer.clone
@buffer = ''
tmp
end
|
#recv ⇒ Object
86
87
88
|
# File 'lib/gamefic/engine.rb', line 86
def recv
@queue.shift
end
|
#select(prompt) ⇒ Object
80
81
82
83
84
85
|
# File 'lib/gamefic/engine.rb', line 80
def select(prompt)
print "#{prompt} "
STDOUT.flush
line = STDIN.gets
@queue.push line.strip
end
|
#send(data) ⇒ Object
74
75
76
77
78
79
|
# File 'lib/gamefic/engine.rb', line 74
def send(data)
@buffer += data
end
|