Class: BSON::Binary
- Inherits:
-
ByteBuffer
- Object
- ByteBuffer
- BSON::Binary
- Defined in:
- lib/bson/types/binary.rb
Overview
An array of binary bytes with a MongoDB subtype. See the subtype constants for reference.
Use this class when storing binary data in documents.
Constant Summary collapse
- SUBTYPE_SIMPLE =
0x00
- SUBTYPE_BYTES =
0x02
- SUBTYPE_UUID =
0x03
- SUBTYPE_MD5 =
0x05
- SUBTYPE_USER_DEFINED =
0x80
Constants inherited from ByteBuffer
BSON::ByteBuffer::BINARY_ENCODING, BSON::ByteBuffer::NULL_BYTE, BSON::ByteBuffer::UTF8_ENCODING
Instance Attribute Summary collapse
-
#subtype ⇒ Object
One of the SUBTYPE_* constants.
Attributes inherited from ByteBuffer
Instance Method Summary collapse
-
#initialize(data = [], subtype = SUBTYPE_SIMPLE) ⇒ Binary
constructor
Create a buffer for storing binary data in MongoDB.
- #inspect ⇒ Object
Methods inherited from ByteBuffer
#==, #append!, #clear, #dump, #get, #get_double, #get_int, #get_long, #more?, #position, #position=, #prepend!, #put, #put_array, #put_binary, #put_double, #put_int, #put_long, #rewind, serialize_cstr, #size, #to_a, #to_s, to_utf8_binary, #unpack
Constructor Details
#initialize(data = [], subtype = SUBTYPE_SIMPLE) ⇒ Binary
Create a buffer for storing binary data in MongoDB.
46 47 48 49 |
# File 'lib/bson/types/binary.rb', line 46 def initialize(data=[], subtype=SUBTYPE_SIMPLE) super(data) @subtype = subtype end |
Instance Attribute Details
#subtype ⇒ Object
One of the SUBTYPE_* constants. Default is SUBTYPE_BYTES.
36 37 38 |
# File 'lib/bson/types/binary.rb', line 36 def subtype @subtype end |
Instance Method Details
#inspect ⇒ Object
51 52 53 |
# File 'lib/bson/types/binary.rb', line 51 def inspect "<BSON::Binary:#{object_id}>" end |