Module: BSON::BigDecimal

Defined in:
lib/logstash/outputs/bson/big_decimal.rb

Overview

Injects behaviour for encoding and decoding BigDecimal values to and from # raw bytes as specified by the BSON spec.

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

BSON_TYPE =

A floating point is type 0x01 in the BSON spec.

1.chr.force_encoding(BINARY).freeze
PACK =

The pack directive is for 8 byte floating points.

"E".freeze

Instance Method Summary collapse

Instance Method Details

#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ String

Get the floating point as encoded BSON.

Examples:

Get the floating point as encoded BSON.

1.221311.to_bson

Returns:

  • (String)

    The encoded string.

See Also:



36
37
38
# File 'lib/logstash/outputs/bson/big_decimal.rb', line 36

def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
  buffer.put_bytes([ self ].pack(PACK))	
end