use of org.jruby.runtime.builtin.IRubyObject in project gocd by gocd.
the class HtmlElementDescription method sub_elements.
@JRubyMethod()
public IRubyObject sub_elements(ThreadContext context) {
Ruby ruby = context.getRuntime();
List<String> subs = findSubElements(element);
IRubyObject[] ary = new IRubyObject[subs.size()];
for (int i = 0; i < subs.size(); ++i) {
ary[i] = ruby.newString(subs.get(i));
}
return ruby.newArray(ary);
}
use of org.jruby.runtime.builtin.IRubyObject in project gocd by gocd.
the class HtmlEntityLookup method get.
/**
* Looks up an HTML entity <code>key</code>.
*
* The description is a bit lacking.
*/
@JRubyMethod()
public IRubyObject get(ThreadContext context, IRubyObject key) {
Ruby ruby = context.getRuntime();
String name = key.toString();
int val = HTMLEntities.get(name);
if (val == -1)
return ruby.getNil();
IRubyObject edClass = ruby.getClassFromPath("Nokogiri::HTML::EntityDescription");
IRubyObject edObj = invoke(context, edClass, "new", ruby.newFixnum(val), ruby.newString(name), ruby.newString(name + " entity"));
return edObj;
}
use of org.jruby.runtime.builtin.IRubyObject in project gocd by gocd.
the class ReaderNode method getNamespaces.
public IRubyObject getNamespaces(ThreadContext context) {
if (namespaces == null)
return ruby.getNil();
RubyHash hash = RubyHash.newHash(ruby);
Set<String> keys = namespaces.keySet();
for (String key : keys) {
String stringValue = namespaces.get(key);
IRubyObject k = stringOrBlank(context.getRuntime(), key);
IRubyObject v = stringOrBlank(context.getRuntime(), stringValue);
if (context.getRuntime().is1_9())
hash.op_aset19(context, k, v);
else
hash.op_aset(context, k, v);
}
return hash;
}
use of org.jruby.runtime.builtin.IRubyObject in project gocd by gocd.
the class XsltExtensionFunction method call.
public static Object call(String method, Object arg) {
if (XsltStylesheet.getRegistry() == null)
return null;
ThreadContext context = (ThreadContext) XsltStylesheet.getRegistry().get("context");
IRubyObject receiver = (IRubyObject) XsltStylesheet.getRegistry().get("receiver");
if (context == null || receiver == null)
return null;
IRubyObject arg0 = JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), arg);
IRubyObject result = RuntimeHelpers.invoke(context, receiver, method, arg0);
return result.toJava(Object.class);
}
use of org.jruby.runtime.builtin.IRubyObject in project gocd by gocd.
the class NokogiriXPathFunction method evaluate.
public Object evaluate(List args) throws XPathFunctionException {
if (args.size() != this.arity) {
throw new XPathFunctionException("arity does not match");
}
Ruby ruby = this.handler.getRuntime();
ThreadContext context = ruby.getCurrentContext();
IRubyObject result = RuntimeHelpers.invoke(context, this.handler, this.name, fromObjectToRubyArgs(args));
return fromRubyToObject(result);
}
Aggregations