Sha256: b883651e31a6b935797e87edf56bc2b1b429453446e2249bd0200a21e20acd97

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_type|
  java_type.new(numeric)
end

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

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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