bool is_rb_raw_color(VALUE cval) { return TYPE(cval) == T_ARRAY && is_a_num(get_from_array(cval, 0)) && is_a_num(get_from_array(cval, 1)) && is_a_num(get_from_array(cval, 2)) && is_a_num(get_from_array(cval, 3)); }
/* point format utilities */ bool is_a_point(VALUE try_point) { /* if it responds to 'x' it's near enough (technically must respond to x AND y) */ /* added the is_a_num() check due to WEIRD bug where FIXNUMS were responding to the 'x' method (wtf?) but returning nil when invoked */ if(rb_respond_to(try_point, rb_intern("x")) && !is_a_num(try_point)) return true; return false; }
/** constructor for TPPoint class **/ static VALUE m_init_TPPoint(int argc, VALUE * argv, VALUE self) { if(argc == 0) { rb_iv_set(self, "@x", INT2FIX(0)); rb_iv_set(self, "@y", INT2FIX(0)); } else if(argc == 2){ if(is_a_num(argv[0]) && is_a_num(argv[1])) { rb_iv_set(self, "@x", argv[0]); rb_iv_set(self, "@y", argv[1]); } else rb_raise(rb_eArgError, "must provide two numbers"); } else rb_raise(rb_eArgError, "please provide x and y args only"); return Qnil; }
bool not_rb_raw_color(VALUE cval) { return TYPE(cval) != T_ARRAY || !is_a_num(get_from_array(cval, 0)); }