Class: DVLA::Herodotus::MultiWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/dvla/herodotus/multi_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*targets) ⇒ MultiWriter

Returns a new instance of MultiWriter.



6
7
8
# File 'lib/dvla/herodotus/multi_writer.rb', line 6

def initialize(*targets)
  @targets = *targets
end

Instance Attribute Details

#targetsObject (readonly)

Returns the value of attribute targets.



4
5
6
# File 'lib/dvla/herodotus/multi_writer.rb', line 4

def targets
  @targets
end

Instance Method Details

#closeObject



21
22
23
24
25
# File 'lib/dvla/herodotus/multi_writer.rb', line 21

def close
  @targets.each do |t|
    t.close unless t.eql? $stdout
  end
end

#write(*args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/dvla/herodotus/multi_writer.rb', line 10

def write(*args)
  @targets.each do |target|
    # If we're writing to a file we remove the colour
    if target != $stdout && args[0].respond_to?(:strip_colour)
      target.write(args[0].strip_colour, *args[1..])
    else
      target.write(*args)
    end
  end
end