Sha256: bff82df619f0ade2af590e61fde3698d57cc23881e6cbfa44e6484ba7abc42a9

Contents?: true

Size: 930 Bytes

Versions: 1

Compression:

Stored size: 930 Bytes

Contents

require 'jruby-coercion'

class Numeric
  include ::Jruby::Coercion::Coercable
end

# java.math.BigDecimal
::Jruby::Coercion::Registry.register_converter(Numeric, java.math.BigDecimal) do |numeric|
  java.math.BigDecimal.new(numeric)
end

::Jruby::Coercion::Registry.register_converter(Integer, java.math.BigDecimal) do |integer|
  java.math.BigDecimal.new(integer)
end

::Jruby::Coercion::Registry.register_converter(Fixnum, java.math.BigDecimal) do |fixnum|
  java.math.BigDecimal.new(fixnum)
end

# java.math.BigInteger
::Jruby::Coercion::Registry.register_converter(Numeric, java.math.BigInteger) do |numeric|
  java.math.BigInteger.new("#{numeric}")
end

::Jruby::Coercion::Registry.register_converter(Integer, java.math.BigInteger) do |integer|
  java.math.BigInteger.new("#{integer}")
end

::Jruby::Coercion::Registry.register_converter(Fixnum, java.math.BigInteger) do |fixnum|
  java.math.BigInteger.new("#{fixnum}")
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jruby-coercion-0.0.2-java lib/jruby-coercion/numeric.rb