Class: Terminalwire::V2::Server::Context::RawInput

Inherits:
Object
  • Object
show all
Defined in:
lib/terminalwire/v2/server/context.rb

Overview

Reads keystroke chunks from a raw input stream. #read returns the next chunk (or nil when the stream closes); #each yields until close.

Instance Method Summary collapse

Constructor Details

#initialize(runtime, sid) ⇒ RawInput

Returns a new instance of RawInput.



165
166
167
168
# File 'lib/terminalwire/v2/server/context.rb', line 165

def initialize(runtime, sid)
  @runtime = runtime
  @sid = sid
end

Instance Method Details

#eachObject



172
173
174
175
176
177
178
# File 'lib/terminalwire/v2/server/context.rb', line 172

def each
  return enum_for(:each) unless block_given?

  while (bytes = read)
    yield bytes
  end
end

#readObject



170
# File 'lib/terminalwire/v2/server/context.rb', line 170

def read = @runtime.read_raw(@sid)