Class: IRB::FileInputMethod
- Inherits:
-
InputMethod
- Object
- InputMethod
- IRB::FileInputMethod
- Defined in:
- lib/irb/input-method.rb
Overview
Use a File for IO with irb, see InputMethod
Constant Summary
Constants inherited from InputMethod
InputMethod::BASIC_WORD_BREAK_CHARACTERS
Instance Attribute Summary
Attributes inherited from InputMethod
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#encoding ⇒ Object
The external encoding for standard input.
-
#eof? ⇒ Boolean
Whether the end of this input method has been reached, returns
true
if there is no more data to read. -
#gets ⇒ Object
Reads the next line from this input method.
-
#initialize(file) ⇒ FileInputMethod
constructor
Creates a new input method object.
-
#inspect ⇒ Object
For debug message.
Methods inherited from InputMethod
#prompting?, #readable_after_eof?, #support_history_saving?, #winsize
Constructor Details
#initialize(file) ⇒ FileInputMethod
Creates a new input method object
137 138 139 140 |
# File 'lib/irb/input-method.rb', line 137 def initialize(file) @io = file.is_a?(IO) ? file : File.open(file) @external_encoding = @io.external_encoding end |
Class Method Details
.open(file, &block) ⇒ Object
126 127 128 129 130 131 132 133 |
# File 'lib/irb/input-method.rb', line 126 def open(file, &block) begin io = new(file) block.call(io) ensure io&.close end end |
Instance Method Details
#close ⇒ Object
168 169 170 |
# File 'lib/irb/input-method.rb', line 168 def close @io.close end |
#encoding ⇒ Object
The external encoding for standard input.
159 160 161 |
# File 'lib/irb/input-method.rb', line 159 def encoding @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.
146 147 148 |
# File 'lib/irb/input-method.rb', line 146 def eof? @io.closed? || @io.eof? end |
#gets ⇒ Object
Reads the next line from this input method.
See IO#gets for more information.
153 154 155 156 |
# File 'lib/irb/input-method.rb', line 153 def gets print @prompt @io.gets end |
#inspect ⇒ Object
For debug message
164 165 166 |
# File 'lib/irb/input-method.rb', line 164 def inspect 'FileInputMethod' end |