Class: DataShift::Logging::MultiIO

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/datashift/logging.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMultiIO

Returns a new instance of MultiIO.



21
22
23
24
# File 'lib/datashift/logging.rb', line 21

def initialize
  @targets = []
  @names = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



41
42
43
# File 'lib/datashift/logging.rb', line 41

def method_missing(method, *args, &block)
  @targets.each { |t| t.send(method, *args, &block) }
end

Instance Attribute Details

#targetsObject (readonly)

Returns the value of attribute targets.



19
20
21
# File 'lib/datashift/logging.rb', line 19

def targets
  @targets
end

Instance Method Details

#add_file(target) ⇒ Object



26
27
28
29
30
31
# File 'lib/datashift/logging.rb', line 26

def add_file(target)
  unless @names.include?(target)
    add( File.open(target, 'a') )
    @names << target
  end
end

#verboseObject



33
34
35
36
37
38
39
# File 'lib/datashift/logging.rb', line 33

def verbose
  target = 'stdout'
  unless @names.include?(target)
    add(STDOUT)
    @names << target
  end
end