@@ -122,7 +122,7 @@ Raw Bytes
122122To write raw bytes to the byte buffer with no transformations, use the
123123``put_byte`` and ``put_bytes`` methods. Each method takes a byte string
124124as its argument and copies this string into the buffer. The ``put_byte``
125- method enforces that the argument is a string of length 1 . ``put_bytes``
125+ method enforces that the argument is a string of length ``1`` . ``put_bytes``
126126accepts any length of strings. The strings can contain null bytes.
127127
128128The following code demonstrates how to write raw bytes to a byte buffer:
@@ -135,15 +135,19 @@ The following code demonstrates how to write raw bytes to a byte buffer:
135135
136136.. note::
137137
138- ``put_byte`` and ``put_bytes`` do not write a BSON type byte before
139- writing the argument to the byte buffer.
138+ ``put_byte`` and ``put_bytes`` do not write a BSON type byte to the
139+ buffer before writing the byte string. This means that the buffer
140+ does not information about the type of data that the raw byte string encodes.
140141
141- Subsequent write methods write objects of particular types in the
142- `BSON specification <http://bsonspec.org/spec.html>`__. The type indicated
143- by the method name takes precedence over the type of the argument.
144- For example, if a floating-point value is passed to ``put_int32``, it is
145- coerced into an integer, and the driver writes the resulting integer to the byte
146- buffer.
142+ Typed Byte Write Methods
143+ ````````````````````````
144+
145+ The write methods described in the following sections write objects of
146+ particular types in the `BSON specification
147+ <http://bsonspec.org/spec.html>`__. The type indicated by the method
148+ name takes precedence over the type of the argument. For example, if a
149+ floating-point value is passed to ``put_int32``, it is coerced into an
150+ integer, and the driver writes the resulting integer to the byte buffer.
147151
148152Strings
149153```````
@@ -331,8 +335,7 @@ ensure that you install v5.0.2 or later of the BSON library.
331335.. note:: BINARY Encoding
332336
333337 ``BSON::Binary`` objects always store the data in ``BINARY`` encoding,
334- regardless of the encoding that the string passed to the constructor
335- was in:
338+ regardless of the encoding of the string passed to the constructor:
336339
337340 .. code-block:: ruby
338341
@@ -421,8 +424,8 @@ cannot be stringified without specifying a representation.
421424 binary.to_uuid(:python_legacy)
422425 # => "00112233-4455-6677-8899aabbccddeeff"
423426
424- To create a legacy UUID BSON::Binary from the string representation of the
425- UUID, use the ``from_uuid`` method specifying the desired representation:
427+ To create a legacy UUID `` BSON::Binary`` from the string representation of the
428+ UUID, use the ``from_uuid`` method and specify the desired representation:
426429
427430.. code-block:: ruby
428431
@@ -576,8 +579,8 @@ value that can emulate decimal rounding with exact precision:
576579BSON::Decimal128 and BigDecimal
577580```````````````````````````````
578581
579- The ``from_bson`` and ``to_bson`` methods from ``BigDecimal`` use the same
580- ``BSON::Decimal128`` methods internally. This leads to some limitations
582+ The ``BigDecimal# from_bson`` and ``BigDecimal# to_bson`` methods use the
583+ equivalent ``BSON::Decimal128`` methods internally. This leads to some limitations
581584on ``BigDecimal`` values that can be serialized to BSON
582585and those that can be deserialized from existing ``decimal128`` BSON
583586values.
@@ -604,7 +607,7 @@ MongoDB. The following list describes the limitations on ``BigDecimal``:
604607 In BSON library v5.0, ``Decimal128`` is deserialized into ``BigDecimal`` by
605608 default. In order to have ``Decimal128`` values in BSON documents
606609 deserialized into ``BSON::Decimal128``, you can set the ``mode: :bson`` option
607- on ``from_bson``.
610+ when calling ``from_bson``.
608611
609612JSON Serialization
610613------------------
@@ -852,7 +855,7 @@ To convert a BSON regular expression to a {+language+} regular expression, call
852855 bson_regexp.compile
853856 # => /^hello.world/m
854857
855- bson_regexp = BSON::Regexp::Raw.new("^hello", "")
858+ bson_regexp = BSON::Regexp::Raw.new("^hello.world ", "")
856859 bson_regexp.compile
857860 # => /^hello.world/
858861
0 commit comments