static SocketOption optionFromArg(IRubyObject opt) { IRubyObject maybeString = TypeConverter.checkStringType(opt.getRuntime(), opt); if (!maybeString.isNil()) { opt = maybeString; } try { if (opt instanceof RubyString || opt instanceof RubySymbol) { String optString = opt.toString(); if (optString.startsWith("SO_")) return SocketOption.valueOf(optString); return SocketOption.valueOf("SO_" + optString); } return SocketOption.valueOf(RubyNumeric.fix2int(opt)); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(opt.getRuntime(), "invalid socket option: " + opt); } }
static SocketOption optionFromArg(IRubyObject opt) { IRubyObject maybeString = TypeConverter.checkStringType(opt.getRuntime(), opt); if (!maybeString.isNil()) { opt = maybeString; } try { if (opt instanceof RubyString || opt instanceof RubySymbol) { String optString = opt.toString(); if (optString.startsWith("SO_")) return SocketOption.valueOf(optString); return SocketOption.valueOf("SO_" + optString); } return SocketOption.valueOf(RubyNumeric.fix2int(opt)); } catch (IllegalArgumentException iae) { throw SocketUtils.sockerr(opt.getRuntime(), "invalid socket option: " + opt); } }
@JRubyMethod(required = 4) public IRubyObject initialize(ThreadContext context, IRubyObject[] args) { family = ProtocolFamily.valueOf(args[0].convertToInteger().getLongValue()); level = SocketLevel.valueOf(args[1].convertToInteger().getLongValue()); option = SocketOption.valueOf(args[2].convertToInteger().getLongValue()); data = args[3].convertToString().getByteList(); intData = Pack.unpackInt_i(ByteBuffer.wrap(data.bytes())); return context.nil; }
@JRubyMethod(required = 4) public IRubyObject initialize(ThreadContext context, IRubyObject[] args) { family = ProtocolFamily.valueOf(args[0].convertToInteger().getLongValue()); level = SocketLevel.valueOf(args[1].convertToInteger().getLongValue()); option = SocketOption.valueOf(args[2].convertToInteger().getLongValue()); data = args[3].convertToString().getByteList(); intData = Pack.unpackInt_i(ByteBuffer.wrap(data.bytes())); return context.nil; }