Sha256: 045bd7a0043946b898e6311c351e52bb77d965aacf170d51a394300e022c4cfa

Contents?: true

Size: 1.16 KB

Versions: 135

Compression:

Stored size: 1.16 KB

Contents

/**
 * Copyright 2005-2007 Xue Yong Zhi
 * Distributed under the BSD License
 */

package com.xruby;

import com.xruby.compiler.*;
import com.xruby.compiler.codegen.*;
import com.xruby.runtime.lang.*;

//This file serves as an example of running Ruby program in Java
public class Example {

    public static void main(String[] args) throws Exception {
        String program_text =
            "def fibonacci(n)\n" +
            "    if n == 1 or n == 0\n" +
            "        n\n" +
            "    else\n" +
            "        fibonacci(n - 1) + fibonacci(n - 2)\n" +
            "    end    \n" +
            "end\n" +
            "\n" +
            "start_time = Time.new.to_f\n" +
            "puts start_time\n" +
            "puts fibonacci(30)\n" +
            "end_time = Time.now.to_f\n" +
            "puts start_time\n" +
            "puts end_time - start_time";

        RubyCompiler compiler = new RubyCompiler();
        CompilationResults codes = compiler.compileString(program_text);
        RubyProgram p = codes.getRubyProgram();

        RubyRuntime.init(args);
        p.invoke();
        RubyRuntime.fini();
    }

}

Version data entries

135 entries across 135 versions & 2 rubygems

Version Path
rhodes-7.6.0 platform/shared/xruby/src/com/xruby/Example.java
rhodes-7.5.1 platform/shared/xruby/src/com/xruby/Example.java
rhodes-7.4.1 platform/shared/xruby/src/com/xruby/Example.java
rhodes-7.1.17 platform/shared/xruby/src/com/xruby/Example.java
rhodes-6.2.0 platform/shared/xruby/src/com/xruby/Example.java
rhodes-6.0.11 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.18 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.17 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.15 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.0.22 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.2 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.0.7 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.0.3 platform/shared/xruby/src/com/xruby/Example.java
rhodes-5.5.0 platform/shared/xruby/src/com/xruby/Example.java
tauplatform-1.0.3 platform/shared/xruby/src/com/xruby/Example.java
tauplatform-1.0.2 platform/shared/xruby/src/com/xruby/Example.java
tauplatform-1.0.1 platform/shared/xruby/src/com/xruby/Example.java
rhodes-3.5.1.12 platform/shared/xruby/src/com/xruby/Example.java
rhodes-3.3.5 platform/shared/xruby/src/com/xruby/Example.java
rhodes-3.4.2 platform/shared/xruby/src/com/xruby/Example.java