Class: GenericIOMethod
- Inherits:
-
IRB::StdioInputMethod
- Object
- IRB::StdioInputMethod
- GenericIOMethod
- Defined in:
- lib/live_console.rb
Overview
The GenericIOMethod is a class that wraps I/O for IRB.
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #close ⇒ Object
- #encoding ⇒ Object
- #eof? ⇒ Boolean
- #file_name ⇒ Object
- #gets ⇒ Object
-
#initialize(input, output = nil, readline = false) ⇒ GenericIOMethod
constructor
call-seq: GenericIOMethod.new io GenericIOMethod.new input, output.
-
#lines ⇒ Object
Returns the user input history.
- #output ⇒ Object
- #print(*a) ⇒ Object
Constructor Details
#initialize(input, output = nil, readline = false) ⇒ GenericIOMethod
call-seq: GenericIOMethod.new io GenericIOMethod.new input, output
Creates a GenericIOMethod, using either a single object for both input and output, or one object for input and another for output.
232 233 234 235 236 237 |
# File 'lib/live_console.rb', line 232 def initialize(input, output = nil, readline=false) @input, @output = input, output @line = [] @line_no = 0 @readline = readline end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
239 240 241 |
# File 'lib/live_console.rb', line 239 def input @input end |
Instance Method Details
#close ⇒ Object
280 281 282 283 |
# File 'lib/live_console.rb', line 280 def close input.close output.close if @output end |
#encoding ⇒ Object
276 277 278 |
# File 'lib/live_console.rb', line 276 def encoding input.external_encoding end |
#eof? ⇒ Boolean
272 273 274 |
# File 'lib/live_console.rb', line 272 def eof? input.eof? end |
#file_name ⇒ Object
268 269 270 |
# File 'lib/live_console.rb', line 268 def file_name input.inspect end |
#gets ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/live_console.rb', line 244 def gets output.print @prompt output.flush line = input.gets if @readline #Return tab completion data as long as we receive input that ends in '\t' while line.chomp =~ /\t\z/n run_completion_proc line.chomp.chop line = input.gets end end @line[@line_no += 1] = line @line[@line_no] end |
#lines ⇒ Object
Returns the user input history.
260 261 262 |
# File 'lib/live_console.rb', line 260 def lines @line.dup end |
#output ⇒ Object
240 241 242 |
# File 'lib/live_console.rb', line 240 def output @output || input end |
#print(*a) ⇒ Object
264 265 266 |
# File 'lib/live_console.rb', line 264 def print(*a) output.print *a end |