Class: IO::InputFilter
- Inherits:
-
IO
show all
- Defined in:
- lib/ttk/Tools/io/filters.rb
Instance Method Summary
collapse
Methods inherited from IO
#compare_stream, dash, print_file, print_io, #testify, #to_diff_for_ttk_log, #to_s_for_ttk_log
Methods included from ImplIndent
#indent
Constructor Details
#initialize(input, &block) ⇒ InputFilter
Returns a new instance of InputFilter.
12
13
14
15
|
# File 'lib/ttk/Tools/io/filters.rb', line 12
def initialize(input, &block)
@input = input
@block = block
end
|
Instance Method Details
#each(&block) ⇒ Object
16
17
18
|
# File 'lib/ttk/Tools/io/filters.rb', line 16
def each(&block)
@input.each { |line| block[@block[line]] }
end
|
#each_byte(&block) ⇒ Object
19
20
21
|
# File 'lib/ttk/Tools/io/filters.rb', line 19
def each_byte(&block)
@input.each_byte { |line| block[@block[line]] }
end
|
#each_line(&block) ⇒ Object
22
23
24
|
# File 'lib/ttk/Tools/io/filters.rb', line 22
def each_line(&block)
@input.each_line { |line| block[@block[line]] }
end
|
#getc ⇒ Object
Also known as:
readchar
25
26
27
|
# File 'lib/ttk/Tools/io/filters.rb', line 25
def getc
@block[@input.getc]
end
|
#gets ⇒ Object
Also known as:
readline
28
29
30
|
# File 'lib/ttk/Tools/io/filters.rb', line 28
def gets
@block[@input.getc]
end
|
31
32
33
|
# File 'lib/ttk/Tools/io/filters.rb', line 31
def read
@block[@input.read]
end
|
#readlines ⇒ Object
34
35
36
|
# File 'lib/ttk/Tools/io/filters.rb', line 34
def readlines
@input.readlines.map(&@block)
end
|