Module: Mongo::Grid::FSBucket::Stream

Extended by:
Stream
Included in:
Stream
Defined in:
lib/mongo/grid/stream.rb,
lib/mongo/grid/stream/read.rb,
lib/mongo/grid/stream/write.rb

Overview

A stream that reads and writes files from/to the FSBucket.

Since:

  • 2.1.0

Defined Under Namespace

Classes: Read, Write

Constant Summary

READ_MODE =

The symbol for opening a read stream.

Since:

  • 2.1.0

:r
WRITE_MODE =

The symbol for opening a write stream.

Since:

  • 2.1.0

:w
MODE_MAP =

Mapping from mode to stream class.

Since:

  • 2.1.0

{
    READ_MODE => Read,
    WRITE_MODE => Write
}.freeze

Instance Method Summary collapse

Instance Method Details

#get(fs, mode, options = {}) ⇒ Stream::Read, Stream::Write

Get a stream for reading/writing files from/to the FSBucket.

Examples:

Get a stream.

FSBucket::Stream.get(fs, FSBucket::READ_MODE, options)

Parameters:

  • fs (FSBucket)

    The GridFS bucket object.

  • mode (FSBucket::READ_MODE, FSBucket::WRITE_MODE)

    The stream mode.

  • options (Hash) (defaults to: {})

    The stream options.

Returns:

Since:

  • 2.1.0



58
59
60
# File 'lib/mongo/grid/stream.rb', line 58

def get(fs, mode, options = {})
  MODE_MAP[mode].new(fs, options)
end