File — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Grid::FileDeprecated

Inherits:

Object

Extended by:

Forwardable

Defined in:

lib/mongo/grid/file.rb,
lib/mongo/grid/file/info.rb,
lib/mongo/grid/file/chunk.rb

Overview

Deprecated.

Please use the ‘stream’ API on a FSBucket instead. Will be removed in driver version 3.0.

A representation of a file in the database.

Defined Under Namespace

Classes: Chunk, Info

Instance Attribute Summary collapse

Instance Method Summarycollapse

Constructor Details

#initialize(data, options = {}) ⇒ File

76 77 78 79 80 # File 'lib/mongo/grid/file.rb', line 76 def initialize(data, options = {}) options = options.merge(:length => data.size) unless options[:length] @info = Info.new(options) initialize_chunks!(data) end

Instance Attribute Details

#chunks ⇒ Array<Chunk>

Returns chunks The file chunks.

37 38 39 # File 'lib/mongo/grid/file.rb', line 37 def chunks @chunks end

#infoFile::Info

Returns info The file information.

40 41 42 # File 'lib/mongo/grid/file.rb', line 40 def info @info end

Instance Method Details

#==(other) ⇒ true, false

52 53 54 55 # File 'lib/mongo/grid/file.rb', line 52 def ==(other) return false unless other.is_a?(File) chunks == other.chunks && info == other.info end

#data ⇒ String

Joins chunks into a string.

| 87 88 89 | # File 'lib/mongo/grid/file.rb', line 87 def data @data ||= Chunk.assemble(chunks) end | | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

#inspect ⇒ String

Gets a pretty inspection of the file.

99 100 101 # File 'lib/mongo/grid/file.rb', line 99 def inspect "#<Mongo::Grid::File:0x#{object_id} filename=#{filename}>" end