Class: Uttk::Dumpers::Dumper

Inherits:
Logger::Backend show all
Includes:
Abstract
Defined in:
lib/uttk/dumpers/Dumper.rb

Overview

The dumper is a specific Logger::Backend.

It react to method calls by writting in the output. The output must be acceded like that:

* Using the print method
* Using the puts method
* Using the << method

If you really need to access to the real outputs use each_output.

You can safely call flush in your methods because this method take care of closed and unflushable outputs.

Direct Known Subclasses

Basic, BasicColor, Html, Mail, Path, Xml, Yaml

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Logger::Backend

#update

Constructor Details

#initialize(output = STDOUT, *args) ⇒ Dumper

Returns a new instance of Dumper.



30
31
32
33
34
35
36
37
# File 'lib/uttk/dumpers/Dumper.rb', line 30

def initialize ( output=STDOUT, *args )
  @outputs = [output]
  while args.first.is_a? IO do
    @outputs << args.shift
  end
  @options = args
  super()
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



28
29
30
# File 'lib/uttk/dumpers/Dumper.rb', line 28

def options
  @options
end

Instance Method Details

#<<(arg) ⇒ Object



66
67
68
69
70
71
# File 'lib/uttk/dumpers/Dumper.rb', line 66

def << ( arg )
  each_output do |o|
    o << arg
  end
  self
end

#each_output(&block) ⇒ Object



47
48
49
# File 'lib/uttk/dumpers/Dumper.rb', line 47

def each_output ( &block )
  @outputs.each(&block)
end

#flushObject



40
41
42
43
44
# File 'lib/uttk/dumpers/Dumper.rb', line 40

def flush
  each_output do |o|
    o.flush if o.respond_to? :flush and (not o.closed?)
  end
end


59
60
61
62
63
# File 'lib/uttk/dumpers/Dumper.rb', line 59

def print ( *args )
  each_output do |o|
    o.print(*args)
  end
end

#puts(*args) ⇒ Object



52
53
54
55
56
# File 'lib/uttk/dumpers/Dumper.rb', line 52

def puts ( *args )
  each_output do |o|
    o.puts(*args)
  end
end