@JRubyMethod public IRubyObject inspect() { String cname = metaClass.getName(); StringBuilder sb = new StringBuilder("<"); sb.append(cname); sb.append(": "); sb.append(this.layoutInspect()); sb.append(">"); return getRuntime().newString(sb.toString()); }
private static void checkArrayType(Ruby runtime, IRubyObject obj) { if (!(obj instanceof RubyArray)) { throw runtime.newTypeError("wrong argument type " + obj.getMetaClass().getName() + " (expected Array)"); } }
@JRubyMethod(name = "initialize_copy", required = 1, visibility = PRIVATE) @Override public IRubyObject initialize_copy(IRubyObject orig) { if (!(orig instanceof RubyRandom)) { throw getRuntime().newTypeError( String.format("wrong argument type %s (expected %s)", orig.getMetaClass() .getName(), getMetaClass().getName())); } random = new RandomType(((RubyRandom) orig).random); return this; }
@JRubyMethod() public static IRubyObject inspect(ThreadContext context, IRubyObject self) { return RubyString.newStringNoCopy(self.getRuntime(), ByteList.plain("#<" + self.getMetaClass().getRealClass().getName() + ": " + hexdigest(context, self, null) + ">")); }
/** num_sadded * */ @JRubyMethod(name = "singleton_method_added") public IRubyObject sadded(IRubyObject name) { throw getRuntime().newTypeError("can't define singleton method " + name + " for " + getType().getName()); }
private IRubyObject[] toAry(ThreadContext context, IRubyObject value) { final IRubyObject ary = Helpers.aryToAry(context, value); if (ary == context.nil) return new IRubyObject[] { value }; if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArray(); throw context.runtime.newTypeError(value.getType().getName() + "#to_ary should return Array"); }
private static String formatReceiver(final IRubyObject object) { if ( object instanceof RubyModule ) { return ((RubyModule) object).getName(); } return object.getMetaClass().getRealClass().getName(); }
@JRubyMethod(name = "new", meta = true) public static final IRubyObject newStructByReference(ThreadContext context, IRubyObject klass, IRubyObject structClass) { if (!(structClass instanceof RubyClass)) { throw context.runtime.newTypeError("wrong argument type " + structClass.getMetaClass().getName() + " (expected Class)"); } if (!((RubyClass) structClass).isKindOfModule(context.runtime.getFFI().structClass)) { throw context.runtime.newTypeError("wrong argument type " + structClass.getMetaClass().getName() + " (expected subclass of FFI::Struct)"); } return new StructByReference(context.runtime, (RubyClass) klass, (RubyClass) structClass, null); }
private static void checkArrayType(Ruby runtime, IRubyObject obj) { if (!(obj instanceof RubyArray)) { throw runtime.newTypeError("wrong argument type " + obj.getMetaClass().getName() + " (expected Array)"); } }
@JRubyMethod(name = "to_s") public final IRubyObject to_s(ThreadContext context) { return RubyString.newString(context.runtime, String.format("#<FFI::StructByValue:%s>", structClass.getName())); }
@JRubyMethod() public static IRubyObject inspect(ThreadContext context, IRubyObject self) { return RubyString.newStringNoCopy(self.getRuntime(), ByteList.plain("#<" + self.getMetaClass().getRealClass().getName() + ": " + hexdigest(context, self, null) + ">")); }
/** num_init_copy * */ @Override @JRubyMethod(name = "initialize_copy", visibility = Visibility.PRIVATE) public IRubyObject initialize_copy(IRubyObject arg) { throw getRuntime().newTypeError("can't copy " + getType().getName()); }
public static IRubyObject[] toAry(ThreadContext context, IRubyObject[] args) { IRubyObject ary; if (args.length == 1 && (ary = Helpers.aryOrToAry(context, args[0])) != context.nil) { if (ary instanceof RubyArray) { args = ((RubyArray) ary).toJavaArray(); } else { throw context.runtime.newTypeError(args[0].getType().getName() + "#to_ary should return Array"); } } return args; }
private static String formatReceiver(final IRubyObject object) { if ( object instanceof RubyModule ) { return ((RubyModule) object).getName(); } return object.getMetaClass().getRealClass().getName(); }
@JRubyMethod(name = "initialize_copy", required = 1, visibility = PRIVATE) @Override public IRubyObject initialize_copy(IRubyObject orig) { if (!(orig instanceof RubyRandom)) { throw getRuntime().newTypeError( String.format("wrong argument type %s (expected %s)", orig.getMetaClass() .getName(), getMetaClass().getName())); } random = new RandomType(((RubyRandom) orig).random); return this; }
private static void checkArrayType(Ruby runtime, IRubyObject obj) { if (!(obj instanceof RubyArray)) { throw runtime.newTypeError("wrong argument type " + obj.getMetaClass().getName() + " (expected Array)"); } }
@JRubyMethod(name = "to_s") public final IRubyObject to_s(ThreadContext context) { return RubyString.newString(context.runtime, String.format("#<FFI::StructByReference:%s>", structClass.getName())); }
@JRubyMethod() public static IRubyObject inspect(ThreadContext ctx, IRubyObject self) { return RubyString.newStringNoCopy(self.getRuntime(), ByteList.plain("#<" + self.getMetaClass().getRealClass().getName() + ": " + hexdigest(ctx, self, null) + ">")); }
/** num_init_copy * */ @Override @JRubyMethod(name = "initialize_copy", visibility = Visibility.PRIVATE) public IRubyObject initialize_copy(IRubyObject arg) { throw getRuntime().newTypeError("can't copy " + getType().getName()); }
public static IRubyObject[] toAry(ThreadContext context, IRubyObject[] args) { IRubyObject ary; if (args.length == 1 && (ary = Helpers.aryOrToAry(context, args[0])) != context.nil) { if (ary instanceof RubyArray) { args = ((RubyArray) ary).toJavaArray(); } else { throw context.runtime.newTypeError(args[0].getType().getName() + "#to_ary should return Array"); } } return args; }