Package org.jruby

Examples of org.jruby.RubyFloat


            // BigDecimal and go back to a double from there
            BigDecimal bdf = rs.getBigDecimal(col);
            if (bdf == null) {
                return runtime.getNil();
            }
            return new RubyFloat(runtime, bdf.doubleValue());
        case BIG_DECIMAL:
            BigDecimal bd = rs.getBigDecimal(col);
            if (bd  == null) {
                return runtime.getNil();
            }
View Full Code Here


        case FLOAT:
            String fvalue = rs.getString(col);
            if (fvalue == null) {
                return runtime.getNil();
            }
            return new RubyFloat(runtime, new BigDecimal(fvalue).doubleValue());
        case BIG_DECIMAL:
            String dvalue = rs.getString(col);
            if (dvalue == null) {
                return runtime.getNil();
            }
View Full Code Here

            int new_p = parseFloatInternal(p, pe);
            if (new_p == -1) {
                res.update(null, p);
                return;
            }
            RubyFloat number = createFloat(p, new_p);
            res.update(number, new_p + 1);
            return;
        }
View Full Code Here

        }
        return fixnum;
    }

    public final RubyFloat getFloat(ThreadContext context, int index, double value) {
        RubyFloat flote = floats[index];
        if (flote == null) {
            return floats[index] = RubyFloat.newFloat(context.runtime, value);
        }
        return flote;
    }
View Full Code Here

    public IRubyObject block(ThreadContext context, IRubyObject[] args) {
      try {
        if (args.length == 0)
          postgresqlConnection.block();
        else {
          RubyFloat timeout = ((RubyNumeric) args[0]).convertToFloat();
          int timeoutMs = (int) (timeout.getDoubleValue() * 1000);
          postgresqlConnection.block(timeoutMs);
        }
        return context.nil;
      } catch (Exception e) {
        throw newPgError(context, e.getLocalizedMessage(), null, getClientEncodingAsJavaEncoding(context));
View Full Code Here

                final Timestamp timestamp = Timestamp.valueOf( value.toString() );
                statement.setTimestamp( index, timestamp ); // assume local time-zone
            }
            else { // Time or DateTime ( ActiveSupport::TimeWithZone.to_time )
                final double time = DateTimeUtils.adjustTimeFromDefaultZone(value);
                final RubyFloat timeValue = context.runtime.newFloat( time );
                statement.setTimestamp( index, DateTimeUtils.convertToTimestamp(timeValue) );
            }
        }
    }
View Full Code Here

            else if ( value instanceof RubyString ) { // yyyy-[m]m-[d]d hh:mm:ss[.f...]
                final Timestamp timestamp = Timestamp.valueOf( value.toString() );
                statement.setTimestamp( index, timestamp ); // assume local time-zone
            }
            else { // DateTime ( ActiveSupport::TimeWithZone.to_time )
                final RubyFloat timeValue = value.convertToFloat(); // to_f
                final Timestamp timestamp = convertToTimestamp(timeValue);

                statement.setTimestamp( index, timestamp, getTimeZoneCalendar("GMT") );
            }
        }
View Full Code Here

            else if ( value instanceof RubyString ) {
                final Time time = Time.valueOf( value.toString() );
                statement.setTime( index, time ); // assume local time-zone
            }
            else { // DateTime ( ActiveSupport::TimeWithZone.to_time )
                final RubyFloat timeValue = value.convertToFloat(); // to_f
                final Time time = new Time(timeValue.getLongValue() * 1000); // millis
                // java.sql.Time is expected to be only up to second precision
                statement.setTime( index, time, getTimeZoneCalendar("GMT") );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jruby.RubyFloat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.