Sha256: b144f113b02749bc43ca3877d689e3610cd9a0971740bf319753f263e682c08f

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

package org.jruby.jubilee.utils;

import org.jcodings.specific.USASCIIEncoding;
import org.jruby.Ruby;
import org.jruby.RubyHash;
import org.jruby.RubyModule;
import org.jruby.RubyString;
import org.jruby.javasupport.JavaEmbedUtils;
import org.jruby.util.ByteList;

import java.util.Map;
import java.util.Map.Entry;

/**
 * Ruby reflection helper utilities.
 *
 * @author Bob McWhirter <bmcwhirt@redhat.com>
 */
public class RubyHelper {

    public static final RubyString toUsAsciiRubyString(final Ruby runtime, final String string) {
        byte[] bytes = new byte[string.length()];
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = (byte) string.charAt(i);
        }
        return toUsAsciiRubyString(runtime, bytes);
    }

    public static final RubyString toUsAsciiRubyString(final Ruby runtime, final byte[] bytes) {
        return RubyString.newString(runtime, new ByteList(bytes, USASCIIEncoding.INSTANCE, false));
    }

    public static final RubyString toUnicodeRubyString(final Ruby runtime, final String string) {
        return RubyString.newUnicodeString(runtime, string);
    }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jubilee-2.1.0.Alpha1-java java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-2.0.0-java java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-2.0.0.beta-java java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-2.0.0.alpha1-java java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-1.1.3-java java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-1.1.2-java java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-1.1.0-java java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-1.1.0.rc3 java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-1.1.0.rc2 java/src/org/jruby/jubilee/utils/RubyHelper.java
jubilee-1.1.0.rc1 java/src/org/jruby/jubilee/utils/RubyHelper.java