Sha256: 3693dd561e3cc05540d093f7220f588e13f6e54615b7a6b84fc502807ab94336

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require 'jruby_coercion'
require 'jruby_coercion/coercable'
require 'jruby_coercion/ruby_to_java/registry'

class Numeric
  include ::JrubyCoercion::Coercable
end

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

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

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

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jruby_coercion-0.0.7-java lib/jruby_coercion/numeric.rb
jruby_coercion-0.0.6-java lib/jruby_coercion/numeric.rb
jruby_coercion-0.0.5-java lib/jruby_coercion/numeric.rb
jruby_coercion-0.0.4-java lib/jruby_coercion/numeric.rb
jruby_coercion-0.0.3-java lib/jruby_coercion/numeric.rb