Class: Tuile::Component::LogWindow::IO

Inherits:
Object
  • Object
show all
Defined in:
lib/tuile/component/log_window.rb

Overview

IO-shaped adapter that forwards each log line to the owning Tuile::Component::LogWindow. Implements both #write (stdlib ‘Logger`) and #puts (loggers that call `output.puts`, e.g. `TTY::Logger`).

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ IO

Returns a new instance of IO.

Parameters:



41
42
43
# File 'lib/tuile/component/log_window.rb', line 41

def initialize(window)
  @window = window
end

Instance Method Details

#closevoid

This method returns an undefined value.

Stdlib ‘Logger` only treats an object as an IO target when it responds to both #write and #close; otherwise it tries to interpret it as a filename. This is a no-op.



61
# File 'lib/tuile/component/log_window.rb', line 61

def close; end

#puts(string) ⇒ void

This method returns an undefined value.

Parameters:

  • string (String)


53
54
55
# File 'lib/tuile/component/log_window.rb', line 53

def puts(string)
  @window.log(string)
end

#write(string) ⇒ void

This method returns an undefined value.

Parameters:

  • string (String)


47
48
49
# File 'lib/tuile/component/log_window.rb', line 47

def write(string)
  @window.log(string.chomp)
end