public static interface RubyDateTimeParsedElementsQuery.DecimalFractionConverter
Map
.
For example, the following implementation converts a decimal fraction into Ruby's Rational
object in JRuby.
import org.jruby.Ruby;
import org.jruby.RubyRational;
public class DecimalFractionToRationalConverter implements RubyDateTimeParsedElementsQuery.DecimalFractionConverter {
public DecimalFractionToRationalConverter(final Ruby ruby) {
this.ruby = ruby;
}
public Object convertDecimalFraction(final long integer, final int nano) {
return RubyRational.newRational(this.ruby, ((long) integer * 1_000_000_000L) + (long) nano, 1_000_000_000L);
}
private final Ruby ruby;
}
Modifier and Type | Method and Description |
---|---|
Object |
convertDecimalFraction(long integer,
int nano)
Converts a decimal fraction, a pair of an integer part and a fraction part, into an arbitrary
Object to be stored in the result Map of RubyDateTimeParsedElementsQuery . |
Object convertDecimalFraction(long integer, int nano)
Object
to be stored in the result Map
of RubyDateTimeParsedElementsQuery
.