Class: Rink::InputMethod::IO
- Inherits:
-
Base
show all
- Defined in:
- lib/rink/input_method/io.rb
Constant Summary
Constants inherited
from Base
Base::STDIN_FILE_NAME
Instance Attribute Summary collapse
Attributes inherited from Base
#filename, #output, #prompt
Instance Method Summary
collapse
Methods inherited from Base
#encoding, #print, #puts, #write
Constructor Details
#initialize(input = $stdin) ⇒ IO
Returns a new instance of IO.
6
7
8
9
10
11
|
# File 'lib/rink/input_method/io.rb', line 6
def initialize(input = $stdin)
super()
@input = input
@line_num = 0
@lines = []
end
|
Instance Attribute Details
Returns the value of attribute input.
4
5
6
|
# File 'lib/rink/input_method/io.rb', line 4
def input
@input
end
|
Instance Method Details
#[](line_number) ⇒ Object
29
30
31
|
# File 'lib/rink/input_method/io.rb', line 29
def [](line_number)
@lines[line_number]
end
|
#eof? ⇒ Boolean
21
22
23
|
# File 'lib/rink/input_method/io.rb', line 21
def eof?
input.eof?
end
|
13
14
15
16
17
18
19
|
# File 'lib/rink/input_method/io.rb', line 13
def gets
print @prompt
line = @lines[@line_num += 1] = input.gets
line += "\n" unless !line || line =~ /\n/
print line if line
line
end
|
#readable_after_eof? ⇒ Boolean
25
26
27
|
# File 'lib/rink/input_method/io.rb', line 25
def readable_after_eof?
true
end
|