Class: IRB::FileInputMethod

Inherits:
InputMethod show all
Defined in:
lib/irb/input-method.rb

Overview

Use a File for IO with irb, see InputMethod

Instance Attribute Summary collapse

Attributes inherited from InputMethod

#prompt

Instance Method Summary collapse

Methods inherited from InputMethod

#readable_after_eof?

Constructor Details

#initialize(file) ⇒ FileInputMethod

Creates a new input method object



98
99
100
101
# File 'lib/irb/input-method.rb', line 98

def initialize(file)
  super
  @io = IRB::MagicFile.open(file)
end

Instance Attribute Details

#file_nameObject (readonly)

The file name of this input method, usually given during initialization.



103
104
105
# File 'lib/irb/input-method.rb', line 103

def file_name
  @file_name
end

Instance Method Details

#encodingObject

The external encoding for standard input.



123
124
125
# File 'lib/irb/input-method.rb', line 123

def encoding
  @io.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.

Returns:

  • (Boolean)


109
110
111
# File 'lib/irb/input-method.rb', line 109

def eof?
  @io.eof?
end

#getsObject

Reads the next line from this input method.

See IO#gets for more information.



116
117
118
119
120
# File 'lib/irb/input-method.rb', line 116

def gets
  print @prompt
  l = @io.gets
  l
end