Class: SocketIOMethod

Inherits:
IRB::StdioInputMethod
  • Object
show all
Defined in:
lib/live_console.rb

Overview

The SocketIOMethod is a class that wraps I/O over a socket for IRB.

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ SocketIOMethod

Returns a new instance of SocketIOMethod.



130
131
132
133
134
# File 'lib/live_console.rb', line 130

def initialize(socket)
	@socket = socket
	@line = []
	@line_no = 0
end

Instance Method Details

#file_nameObject



153
154
155
# File 'lib/live_console.rb', line 153

def file_name
	@socket.inspect
end

#getsObject



136
137
138
139
140
141
142
# File 'lib/live_console.rb', line 136

def gets
	@socket.print @prompt
	@socket.flush
	@line[@line_no += 1] = @socket.gets
	@socket.flush
	@line[@line_no]
end


149
150
151
# File 'lib/live_console.rb', line 149

def print(*a)
	@socket.print *a
end