Class: Rink::InputMethod::File

Inherits:
Base show all
Defined in:
lib/rink/input_method/file.rb

Constant Summary

Constants inherited from Base

Base::STDIN_FILE_NAME

Instance Attribute Summary

Attributes inherited from Base

#filename, #output, #prompt

Instance Method Summary collapse

Methods inherited from Base

#encoding, #print, #puts, #readable_after_eof?, #write

Constructor Details

#initialize(file) ⇒ File

Returns a new instance of File.



4
5
6
7
8
9
# File 'lib/rink/input_method/file.rb', line 4

def initialize(file)
  super
  @io = file
  @line_num = 0
  @lines = []
end

Instance Method Details

#eof?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rink/input_method/file.rb', line 15

def eof?
  @io.eof?
end

#getsObject



19
20
21
22
23
24
25
# File 'lib/rink/input_method/file.rb', line 19

def gets
  print @prompt
  line = @lines[@line_num += 1] = @io.gets
  line += "\n" unless !line || line =~ /\n/
  print(line)
  line
end

#inputObject



11
12
13
# File 'lib/rink/input_method/file.rb', line 11

def input
  @io
end