Sha256: 955b814b8bf8f9f6a3a2c44f32bd5af13e4009eb8e0bb604432ae51077a92bc1

Contents?: true

Size: 699 Bytes

Versions: 7

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true
# NOTE remove once minimum required Ruby version is at least 2.4
Float.prepend (Module.new do
  def truncate *args
    if args.length == 1
      if (precision = Integer args.shift) == 0
        super
      elsif precision > 0
        precision_factor = 10.0 ** precision
        (self * precision_factor).to_i / precision_factor
      else
        precision_factor = 10 ** precision.abs
        (self / precision_factor).to_i * precision_factor
      end
    else
      super
    end
  end
end) if (Float.instance_method :truncate).arity == 0

Integer.prepend (Module.new do
  def truncate *args
    super()
  end
end) if (Integer.instance_method :truncate).arity == 0

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
asciidoctor-pdf-1.5.0.beta.8 lib/asciidoctor/pdf/ext/core/numeric.rb
asciidoctor-pdf-1.5.0.beta.7 lib/asciidoctor/pdf/ext/core/numeric.rb
asciidoctor-pdf-1.5.0.beta.6 lib/asciidoctor/pdf/ext/core/numeric.rb
asciidoctor-pdf-1.5.0.beta.5 lib/asciidoctor-pdf/core_ext/numeric.rb
asciidoctor-pdf-1.5.0.beta.4 lib/asciidoctor-pdf/core_ext/numeric.rb
asciidoctor-pdf-1.5.0.beta.3 lib/asciidoctor-pdf/core_ext/numeric.rb
asciidoctor-pdf-1.5.0.beta.2 lib/asciidoctor-pdf/core_ext/numeric.rb