Sha256: 68dd643dcc2f09d6020119a4550131a0a80b32268f88c8fdc85c84773f718094

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

package com.jrjackson;

import java.io.IOException;
import java.util.*;

import java.math.BigDecimal;
import java.math.BigInteger;

import org.jruby.*;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.ext.bigdecimal.RubyBigDecimal;
import org.jruby.runtime.Block;

public class RubyUtils
{
  
  public static RubyObject rubyObject(Ruby ruby, Object node)
  {
    return (RubyObject)JavaUtil.convertJavaToRuby(ruby, node);
  }

  public static RubyString rubyString(Ruby ruby, String node)
  {
    return ruby.newString(node);
  }

  public static RubySymbol rubySymbol(Ruby ruby, String node)
  {
    return RubySymbol.newSymbol(ruby, node);
  }

  public static RubyArray rubyArray(Ruby ruby, Object[] arg)
  {
    return (RubyArray)JavaUtil.convertJavaToRuby(ruby, arg);
  }

  public static RubyArray rubyArray(Ruby ruby, List arg)
  {
    return (RubyArray)JavaUtil.convertJavaToRuby(ruby, arg);
  }
  
  public static RubyHash rubyHash(Ruby ruby, Map arg)
  {
    return (RubyHash)JavaUtil.convertJavaToRuby(ruby, arg);
  }

  public static RubyFixnum rubyFixnum(Ruby ruby, int arg)
  {
    return ruby.newFixnum(arg);
  }

  public static RubyFixnum rubyFixnum(Ruby ruby, long arg)
  {
    return ruby.newFixnum(arg);
  }

  public static RubyBignum rubyBignum(Ruby ruby, BigInteger arg)
  {
    return RubyBignum.newBignum(ruby, arg);
  }

  public static RubyFloat rubyFloat(Ruby ruby, double arg)
  {
    return ruby.newFloat(arg);
  }

  public static RubyBigDecimal rubyBigDecimal(Ruby ruby, BigDecimal arg)
  {
    return new RubyBigDecimal(ruby, arg);
  }

  public static RubyBoolean rubyBoolean(Ruby ruby, Boolean arg)
  {
    return ruby.newBoolean(arg);
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jrjackson-0.2.0 src/main/java/com/jrjackson/RubyUtils.java