package hitimes;

import java.lang.Math;
import java.lang.System;

import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.anno.JRubyModule;
import org.jruby.anno.JRubyConstant;
import org.jruby.runtime.Visibility;

import org.jruby.Ruby;
import org.jruby.RubyClass;
import org.jruby.RubyException;
import org.jruby.RubyModule;
import org.jruby.RubyObject;

import org.jruby.exceptions.RaiseException;

import org.jruby.runtime.builtin.IRubyObject;


/**
 * @author <a href="mailto:jeremy@hinegardner.org">Jeremy Hinegardner</a>
 */
@JRubyModule( name = "Hitimes" )
public class Hitimes {

    public static final double INSTANT_CONVERSION_FACTOR = 1000000000d;

    private static final Ruby __ruby__ = Ruby.getGlobalRuntime();

    public static RubyClass hitimesIntervalClass;
    /**
     * Create the Hitimes module and add it to the Ruby runtime.
     */
    public static RubyModule createHitimesModule( Ruby runtime ) {
        RubyModule mHitimes = runtime.defineModule("Hitimes");
        mHitimes.defineConstant("INSTANT_CONVERSION_FACTOR", __ruby__.newFloat(INSTANT_CONVERSION_FACTOR));
        mHitimes.defineAnnotatedMethods( Hitimes.class );

        RubyClass  cStandardError = runtime.getStandardError();
        RubyClass  cHitimesError  = mHitimes.defineClassUnder("Error", cStandardError, cStandardError.getAllocator());

        RubyClass  cHitimesStats  = mHitimes.defineClassUnder("Stats", runtime.getObject(), HitimesStats.ALLOCATOR );
        cHitimesStats.defineAnnotatedMethods( HitimesStats.class );

        RubyClass  cHitimesInterval  = mHitimes.defineClassUnder("Interval", runtime.getObject(), HitimesInterval.ALLOCATOR );
        Hitimes.hitimesIntervalClass = cHitimesInterval;
        cHitimesInterval.defineAnnotatedMethods( HitimesInterval.class );

        return mHitimes;
    }

    static RaiseException newHitimesError( Ruby runtime, String message ) {
        RubyClass errorClass = runtime.getModule("Hitimes").getClass( "Error" );
        return RaiseException.from( runtime, errorClass, message );
    }


    @JRubyMethod( name = "raw_instant", module = true )
    public static IRubyObject rawInstant(IRubyObject self) {
      return __ruby__.newFixnum( System.nanoTime() );
    }

}

@@ -2015,16 +2015,20 @@
  return 
+new 
 RaiseExc
@@ -2037,13 +2037,36 @@
 tion
-.from
+( RubyException.newException
 ( ru
@@ -2092,16 +2092,24 @@
 message 
+), true 
 );%0A    %7D

Revert "Fix deprecated exception"