Class: IO::OutputFilter

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(output, &block) ⇒ OutputFilter



42
43
44
45
# File 'lib/ttk/Tools/io/filters.rb', line 42

def initialize(output, &block)
  @output = output
  @block = block
end

Instance Method Details

#<<(o) ⇒ Object



46
47
48
49
# File 'lib/ttk/Tools/io/filters.rb', line 46

def <<(o)
  @output.write @block[o.to_s]
  self
end


50
51
52
# File 'lib/ttk/Tools/io/filters.rb', line 50

def print(*args)
  @output.print args.map { |x| @block[x.to_s] }
end

#printf(fmt, *args) ⇒ Object



53
54
55
# File 'lib/ttk/Tools/io/filters.rb', line 53

def printf(fmt, *args)
  @output.printf fmt, args.map { |x| @block[x] }
end

#putc(c) ⇒ Object



56
57
58
# File 'lib/ttk/Tools/io/filters.rb', line 56

def putc(c)
  @output.putc @block[c]
end

#puts(*args) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/ttk/Tools/io/filters.rb', line 59

def puts(*args)
  if args.size == 0
	@output.print @block["\n"]
  else
	@output.print args.map { |x| @block[x.to_s] }
  end
end

#write(o) ⇒ Object



66
67
68
# File 'lib/ttk/Tools/io/filters.rb', line 66

def write(o)
  @output.write @block[o.to_s]
end