@@ -270,7 +270,7 @@ The data and the subtype can be retrieved from ``Binary`` instances using
270
270
was in:
271
271
272
272
.. code-block:: ruby
273
-
273
+
274
274
str = "binary_string"
275
275
str.encoding
276
276
# => #<Encoding:US-ASCII>
@@ -343,10 +343,10 @@ cannot be stringified without specifying a representation.
343
343
344
344
binary = BSON::Binary.new("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF".force_encoding('BINARY'), :uuid_old)
345
345
=> <BSON::Binary:0x46942046606480 type=uuid data=0x0011223344556677...>
346
-
346
+
347
347
binary.to_uuid
348
348
# => ArgumentError (Representation must be specified for BSON::Binary objects of type :uuid_old)
349
-
349
+
350
350
binary.to_uuid(:csharp_legacy)
351
351
# => "33221100-5544-7766-8899aabbccddeeff"
352
352
@@ -362,13 +362,13 @@ UUID, use the ``from_uuid`` method specifying the desired representation:
362
362
.. code-block:: ruby
363
363
364
364
uuid_str = "00112233-4455-6677-8899-aabbccddeeff"
365
-
365
+
366
366
BSON::Binary.from_uuid(uuid_str, :csharp_legacy)
367
367
# => <BSON::Binary:0x46986653650480 type=uuid_old data=0x3322110055447766...>
368
368
369
369
BSON::Binary.from_uuid(uuid_str, :java_legacy)
370
370
# => <BSON::Binary:0x46986653663960 type=uuid_old data=0x7766554433221100...>
371
-
371
+
372
372
BSON::Binary.from_uuid(uuid_str, :python_legacy)
373
373
# => <BSON::Binary:0x46986653686300 type=uuid_old data=0x0011223344556677...>
374
374
@@ -485,17 +485,17 @@ strings to be used instead.
485
485
stringified when used as hash keys:
486
486
487
487
.. code-block:: ruby
488
-
489
- Hash.from_bson({foo: 'bar'}.to_bson)
490
- # => {"foo"=>"bar"}
491
-
492
- Hash.from_bson({1 => 2}.to_bson)
493
- # => {"1"=>2}
488
+
489
+ Hash.from_bson({foo: 'bar'}.to_bson)
490
+ # => {"foo"=>"bar"}
491
+
492
+ Hash.from_bson({1 => 2}.to_bson)
493
+ # => {"1"=>2}
494
494
495
495
By default, the BSON library encodes ``Symbol`` hash values as strings and
496
496
decodes BSON symbols into Ruby ``Symbol`` values:
497
497
498
- .. code-block:: ruby
498
+ .. code-block:: ruby
499
499
500
500
{foo: :bar}.to_bson.to_s
501
501
# => "\x12\x00\x00\x00\x02foo\x00\x04\x00\x00\x00bar\x00\x00"
@@ -511,7 +511,7 @@ decodes BSON symbols into Ruby ``Symbol`` values:
511
511
To force encoding of Ruby symbols to BSON symbols, wrap the Ruby symbols in
512
512
``BSON::Symbol::Raw``:
513
513
514
- .. code-block:: ruby
514
+ .. code-block:: ruby
515
515
516
516
{foo: BSON::Symbol::Raw.new(:bar)}.to_bson.to_s
517
517
# => "\x12\x00\x00\x00\x0Efoo\x00\x04\x00\x00\x00bar\x00\x00"
@@ -571,11 +571,11 @@ millisecond.
571
571
572
572
.. code-block:: ruby
573
573
574
- time = Time.utc(1960, 1, 1, 0, 0, 0, 999_999)
575
- time.to_f
576
- # => -315619199.000001
577
- time.floor(3).to_f
578
- # => -315619199.001
574
+ time = Time.utc(1960, 1, 1, 0, 0, 0, 999_999)
575
+ time.to_f
576
+ # => -315619199.000001
577
+ time.floor(3).to_f
578
+ # => -315619199.001
579
579
580
580
.. note::
581
581
0 commit comments