Class: DataShift::Logging::MultiIO
- Inherits:
-
Object
- Object
- DataShift::Logging::MultiIO
- Includes:
- Singleton
- Defined in:
- lib/datashift/logging.rb
Instance Attribute Summary collapse
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #add_file(target) ⇒ Object
-
#initialize ⇒ MultiIO
constructor
A new instance of MultiIO.
- #method_missing(method, *args, &block) ⇒ Object
- #verbose ⇒ Object
Constructor Details
#initialize ⇒ MultiIO
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
#targets ⇒ Object (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 |
#verbose ⇒ Object
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 |