Class: Dratools::ProgressReporter::ClearingIO

Inherits:
Object
  • Object
show all
Defined in:
lib/dratools/progress_reporter.rb

Overview

通常の出力の直前に、表示中の進捗行を消す IO ラッパー。

Instance Method Summary collapse

Constructor Details

#initialize(io, reporter) ⇒ ClearingIO

Returns a new instance of ClearingIO.



12
13
14
15
# File 'lib/dratools/progress_reporter.rb', line 12

def initialize(io, reporter)
  @io = io
  @reporter = reporter
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



40
41
42
43
44
# File 'lib/dratools/progress_reporter.rb', line 40

def method_missing(name, ...)
  return super unless @io.respond_to?(name)

  @io.public_send(name, ...)
end

Instance Method Details

#flushObject



32
33
34
# File 'lib/dratools/progress_reporter.rb', line 32

def flush
  @io.flush
end


22
23
24
25
# File 'lib/dratools/progress_reporter.rb', line 22

def print(*args)
  @reporter.finish
  @io.print(*args)
end

#puts(*args) ⇒ Object



17
18
19
20
# File 'lib/dratools/progress_reporter.rb', line 17

def puts(*args)
  @reporter.finish
  @io.puts(*args)
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/dratools/progress_reporter.rb', line 46

def respond_to_missing?(name, include_private = false)
  @io.respond_to?(name, include_private) || super
end

#tty?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/dratools/progress_reporter.rb', line 36

def tty?
  @io.respond_to?(:tty?) && @io.tty?
end

#write(*args) ⇒ Object



27
28
29
30
# File 'lib/dratools/progress_reporter.rb', line 27

def write(*args)
  @reporter.finish
  @io.write(*args)
end