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.
65
66
67
68
|
# File 'lib/gamefic/engine.rb', line 65
def initialize
@queue = Array.new
@buffer = ''
end
|
Instance Method Details
#flush ⇒ Object
69
70
71
72
73
74
|
# File 'lib/gamefic/engine.rb', line 69
def flush
tmp = @buffer.clone
@buffer = ''
tmp
end
|
#recv ⇒ Object
87
88
89
|
# File 'lib/gamefic/engine.rb', line 87
def recv
@queue.shift
end
|
#select(prompt) ⇒ Object
81
82
83
84
85
86
|
# File 'lib/gamefic/engine.rb', line 81
def select(prompt)
print "#{prompt} "
STDOUT.flush
line = STDIN.gets
@queue.push line.strip
end
|
#send(data) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/gamefic/engine.rb', line 75
def send(data)
@buffer += data
end
|