/* * call-seq: * new(...) * * Optional Named Parameters (as a single hash): * * :data * * Data to be written, or was read from the queue * * :descriptor * * Desciptor * * Example: * message = WMQ::Message.new * * Example: * message = WMQ::Message.new(:data=>'Hello World', * :descriptor=> { * :format => WMQ::MQFMT_STRING * }) */ VALUE Message_initialize(int argc, VALUE *argv, VALUE self) { VALUE parms = Qnil; VALUE proc = Qnil; /* Extract optional parameter */ rb_scan_args(argc, argv, "01", &parms); if (NIL_P(parms)) { rb_iv_set(self, "@data", Qnil); rb_iv_set(self, "@headers", rb_ary_new()); rb_iv_set(self, "@descriptor", rb_hash_new()); } else { VALUE val; Check_Type(parms, T_HASH); rb_iv_set(self, "@data", rb_hash_aref(parms, ID2SYM(ID_data))); val = rb_hash_aref(parms, ID2SYM(ID_headers)); if (NIL_P(val)) { rb_iv_set(self, "@headers", rb_ary_new()); } else { rb_iv_set(self, "@headers", val); } val = rb_hash_aref(parms, ID2SYM(ID_descriptor)); if (NIL_P(val)) { rb_iv_set(self, "@headers", rb_hash_new()); } else { rb_iv_set(self, "@descriptor", val); } } return Qnil; }