Sha256: 8f62c601aec5730c3a17d44d37fb5c7daab75c540d2f088da1904a5a73526e0e

Contents?: true

Size: 669 Bytes

Versions: 3

Compression:

Stored size: 669 Bytes

Contents

# 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

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-pdf-1.5.0.beta.1 lib/asciidoctor-pdf/core_ext/numeric.rb
asciidoctor-pdf-1.5.0.alpha.18 lib/asciidoctor-pdf/core_ext/numeric.rb
asciidoctor-pdf-1.5.0.alpha.17 lib/asciidoctor-pdf/core_ext/numeric.rb