module BSON::String
def to_bson(buffer = ByteBuffer.new)
- Since: - 2.0.0
Other tags:
- See: http://bsonspec.org/#/specification -
Returns:
-
(BSON::ByteBuffer)
- The buffer with the encoded object.
Raises:
-
(EncodingError)
- If the string is not UTF-8.
Other tags:
- Example: Get the string as encoded BSON. -
def to_bson(buffer = ByteBuffer.new) buffer.put_string(self) end
def to_bson_key
- Since: - 2.0.0
Other tags:
- See: http://bsonspec.org/#/specification -
Returns:
-
(String)
- The encoded string.
Raises:
-
(EncodingError)
- If the string is not UTF-8.
Other tags:
- Example: Get the string as key name. -
def to_bson_key self end
def to_bson_object_id
- Since: - 2.0.0
Returns:
-
(String)
- The raw object id bytes.
Raises:
-
(BSON::Error::InvalidObjectId)
- If the string is not 12 elements.
Other tags:
- Note: - This is used for repairing legacy bson data.
Other tags:
- Example: Convert the string to an object id. -
def to_bson_object_id ObjectId.repair(self) end
def to_hex_string
- Since: - 2.0.0
Returns:
-
(String)
- The string as hex.
Other tags:
- Example: Convert the string to hex. -
def to_hex_string unpack("H*")[0] end