Sha256: 15e4fed91bb9ce4cd5fa829c2b66ea97f6cd7f2e573623436652b3dcaf9dc834

Contents?: true

Size: 559 Bytes

Versions: 36

Compression:

Stored size: 559 Bytes

Contents

module Arql
  class MultiIO
    def initialize(*targets)
      @targets = targets
    end

    def write(*args)
      @targets.each do |t|
        if t.isatty
          t.write(*args)
        else
          t.write(*(args.map { |str| str.gsub(/\e\[(\d+)m/, '')}))
        end
        t.flush
      end
    end

    def close
      @targets.each(&:close)
    end

    def <<(target)
      @targets ||= []
      @targets << target
    end

    def delete(io)
      @targets.delete(io)
    end

    def include?(io)
      @targets.include?(io)
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
arql-0.4.11 lib/arql/multi_io.rb
arql-0.4.10 lib/arql/multi_io.rb
arql-0.4.8 lib/arql/multi_io.rb
arql-0.4.7 lib/arql/multi_io.rb
arql-0.4.6 lib/arql/multi_io.rb
arql-0.4.3 lib/arql/multi_io.rb
arql-0.4.2 lib/arql/multi_io.rb
arql-0.4.1 lib/arql/multi_io.rb
arql-0.4.0 lib/arql/multi_io.rb
arql-0.3.31 lib/arql/multi_io.rb
arql-0.3.30 lib/arql/multi_io.rb
arql-0.3.29 lib/arql/multi_io.rb
arql-0.3.28 lib/arql/multi_io.rb
arql-0.3.27 lib/arql/multi_io.rb
arql-0.3.26 lib/arql/multi_io.rb
arql-0.3.25 lib/arql/multi_io.rb
arql-0.3.24 lib/arql/multi_io.rb
arql-0.3.23 lib/arql/multi_io.rb
arql-0.3.22 lib/arql/multi_io.rb
arql-0.3.21 lib/arql/multi_io.rb