Class: BSON::Decimal128::Builder::FromBigDecimal Private

Inherits:
Object
  • Object
show all
Defined in:
lib/bson/decimal128/builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Helper class for parsing a BigDecimal into Decimal128 high and low bits.

Since:

  • 4.2.0

Instance Method Summary collapse

Constructor Details

#initialize(big_decimal) ⇒ FromBigDecimal

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the FromBigDecimal Builder object.

Examples:

Create the FromBigDecimal builder.

Builder::FromBigDecimal.new(big_decimal)

Parameters:

  • big_decimal (BigDecimal)

    The big decimal object to create a Decimal128 from.

Since:

  • 4.2.0



286
287
288
# File 'lib/bson/decimal128/builder.rb', line 286

def initialize(big_decimal)
  @big_decimal = big_decimal
end

Instance Method Details

#bitsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the bits representing the Decimal128 that the big decimal corresponds to.

Examples:

Get the bits for the Decimal128 object created from the big decimal.

builder.bits

Returns:

  • (Array)

    Tuple of the low and high bits.

Since:

  • 4.2.0



298
299
300
301
302
303
304
# File 'lib/bson/decimal128/builder.rb', line 298

def bits
  if special?
    to_special_bits
  else
    to_bits
  end
end