Search in sources :

Example 1 with RubyObject

use of org.jruby.RubyObject in project nokogiri by sparklemotion.

the class NokogiriHandler method isFromFragmentHandler.

private boolean isFromFragmentHandler() {
    if (object != null && object instanceof RubyObject) {
        RubyObject rubyObj = (RubyObject) object;
        IRubyObject document = rubyObj.getInstanceVariable("@document");
        if (document != null) {
            String name = document.getMetaClass().getName();
            if ("Nokogiri::XML::FragmentHandler".equals(name)) {
                return true;
            }
        }
    }
    return false;
}
Also used : IRubyObject(org.jruby.runtime.builtin.IRubyObject) RubyObject(org.jruby.RubyObject) IRubyObject(org.jruby.runtime.builtin.IRubyObject)

Example 2 with RubyObject

use of org.jruby.RubyObject in project gocd by gocd.

the class NokogiriHandler method isFromFragmentHandler.

private boolean isFromFragmentHandler() {
    if (object != null && object instanceof RubyObject) {
        RubyObject rubyObj = (RubyObject) object;
        IRubyObject document = rubyObj.getInstanceVariable("@document");
        if (document != null) {
            String name = document.getMetaClass().getName();
            if ("Nokogiri::XML::FragmentHandler".equals(name)) {
                return true;
            }
        }
    }
    return false;
}
Also used : IRubyObject(org.jruby.runtime.builtin.IRubyObject) RubyObject(org.jruby.RubyObject) IRubyObject(org.jruby.runtime.builtin.IRubyObject)

Example 3 with RubyObject

use of org.jruby.RubyObject in project cucumber-jvm by cucumber.

the class JRubyBackend method executeStepdef.

void executeStepdef(RubyObject stepdef, I18n i18n, Object[] args) {
    ArrayList<IRubyObject> jrubyArgs = new ArrayList<IRubyObject>();
    // jrubyWorld.@__gherkin_i18n = i18n
    RubyObject jrubyI18n = (RubyObject) JavaEmbedUtils.javaToRuby(stepdef.getRuntime(), i18n);
    currentWorld.callMethod("instance_variable_set", new IRubyObject[] { stepdef.getRuntime().newSymbol("@__gherkin_i18n"), jrubyI18n });
    jrubyArgs.add(currentWorld);
    for (Object o : args) {
        if (o == null) {
            jrubyArgs.add(null);
        } else if (o instanceof DataTable) {
            //Add a datatable as it stands...
            jrubyArgs.add(JavaEmbedUtils.javaToRuby(stepdef.getRuntime(), o));
        } else {
            jrubyArgs.add(stepdef.getRuntime().newString((String) o));
        }
    }
    stepdef.callMethod("execute", jrubyArgs.toArray(new IRubyObject[jrubyArgs.size()]));
}
Also used : DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) RubyObject(org.jruby.RubyObject) IRubyObject(org.jruby.runtime.builtin.IRubyObject) IRubyObject(org.jruby.runtime.builtin.IRubyObject) RubyObject(org.jruby.RubyObject) IRubyObject(org.jruby.runtime.builtin.IRubyObject)

Aggregations

RubyObject (org.jruby.RubyObject)3 IRubyObject (org.jruby.runtime.builtin.IRubyObject)3 DataTable (cucumber.api.DataTable)1 ArrayList (java.util.ArrayList)1