class Pocolog::BaseCopyConfig
Attributes
output[R]
Public Class Methods
new(io)
click to toggle source
Calls superclass method
Pocolog::ModeConfig.new
# File bin/pocolog, line 38 def initialize(io) if io.size > 1 && self.class.single_io? raise ArgumentError, "too much input files given on command line" end super end
single_io?()
click to toggle source
# File bin/pocolog, line 37 def self.single_io?; true end
Public Instance Methods
init() { |first, to| ... }
click to toggle source
# File bin/pocolog, line 45 def init(&block) if io.any? { |input| input.path == output } # Special case ... generate a temporary file and move the file # only when we're done begin save_output = @output @output = "#{@output}.log" init(&block) FileUtils.rm_f save_output FileUtils.mv output, save_output return rescue FileUtils.rm_f output raise end end File.open(output, 'w', :encoding => 'BINARY') do |to| if self.class.single_io? yield(io.first, to) else yield(io, to) end end end
output=(file)
click to toggle source
# File bin/pocolog, line 30 def output=(file) if io.empty? raise ArgumentError, "no input file given" end @output = file end