Sha256: d45aaec4a4c8cec4d34bfa7ea2617c10230d63049e83a95d894487b50d014838

Contents?: true

Size: 556 Bytes

Versions: 1

Compression:

Stored size: 556 Bytes

Contents

# encoding: UTF-8

require 'json'
require 'json-write-stream/yielding'
require 'json-write-stream/stateful'

class JsonWriteStream
  class << self
    def from_stream(stream)
      if block_given?
        yield writer = YieldingWriter.new(stream)
        writer.close
      else
        StatefulWriter.new(stream)
      end
    end

    def open(file)
      handle = File.open(file, 'w')

      if block_given?
        yield writer = YieldingWriter.new(handle)
        writer.close
      else
        StatefulWriter.new(handle)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json-write-stream-1.0.0 lib/json-write-stream.rb