Class: IRBRemote::InputMethod
- Inherits:
-
IRB::InputMethod
- Object
- IRB::InputMethod
- IRBRemote::InputMethod
- Defined in:
- lib/irb_remote/input_method.rb
Instance Method Summary collapse
-
#encoding ⇒ Object
The external encoding for standard input.
-
#eof? ⇒ Boolean
Whether the end of this input method has been reached, returns
trueif there is no more data to read. -
#gets ⇒ Object
Reads the next line from this input method.
-
#initialize(input, output) ⇒ InputMethod
constructor
Creates a new input method object.
-
#line(line_no) ⇒ Object
Returns the current line number for #io.
-
#readable_after_eof? ⇒ Boolean
Whether this input method is still readable when there is no more data to read.
Constructor Details
#initialize(input, output) ⇒ InputMethod
Creates a new input method object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/irb_remote/input_method.rb', line 4 def initialize(input, output) super() @line_no = 0 @line = [] @eof = false input.set_encoding(IRB.conf[:LC_MESSAGES].encoding, '-') output.set_encoding(IRB.conf[:LC_MESSAGES].encoding, '-') @stdin = input @stdout = output end |
Instance Method Details
#encoding ⇒ Object
The external encoding for standard input.
53 54 55 |
# File 'lib/irb_remote/input_method.rb', line 53 def encoding @stdin.external_encoding end |
#eof? ⇒ Boolean
Whether the end of this input method has been reached, returns true if there is no more data to read.
See IO#eof? for more information.
31 32 33 |
# File 'lib/irb_remote/input_method.rb', line 31 def eof? @stdin.eof? end |
#gets ⇒ Object
Reads the next line from this input method.
See IO#gets for more information.
21 22 23 24 25 |
# File 'lib/irb_remote/input_method.rb', line 21 def gets @stdout.print @prompt line = @stdin.gets @line[@line_no += 1] = line end |
#line(line_no) ⇒ Object
Returns the current line number for #io.
#line counts the number of times #gets is called.
See IO#lineno for more information.
48 49 50 |
# File 'lib/irb_remote/input_method.rb', line 48 def line(line_no) @line[line_no] end |
#readable_after_eof? ⇒ Boolean
Whether this input method is still readable when there is no more data to read.
See IO#eof for more information.
39 40 41 |
# File 'lib/irb_remote/input_method.rb', line 39 def readable_after_eof? true end |