method
configure
v1_9_1_378 -
Show latest stable
-
0 notes -
Class: State
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5 (38)
- 2_6_3 (0)
- What's this?
configure(p1)
public
Hide source
VALUE cState_configure(VALUE self, VALUE opts) { VALUE tmp; GET_STATE(self); tmp = rb_convert_type(opts, T_HASH, "Hash", "to_hash"); if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h"); if (NIL_P(tmp)) { rb_raise(rb_eArgError, "opts has to be hash like or convertable into a hash"); } opts = tmp; tmp = rb_hash_aref(opts, ID2SYM(i_indent)); if (RTEST(tmp)) { Check_Type(tmp, T_STRING); state->indent = tmp; } tmp = rb_hash_aref(opts, ID2SYM(i_space)); if (RTEST(tmp)) { Check_Type(tmp, T_STRING); state->space = tmp; } tmp = rb_hash_aref(opts, ID2SYM(i_space_before)); if (RTEST(tmp)) { Check_Type(tmp, T_STRING); state->space_before = tmp; } tmp = rb_hash_aref(opts, ID2SYM(i_array_nl)); if (RTEST(tmp)) { Check_Type(tmp, T_STRING); state->array_nl = tmp; } tmp = rb_hash_aref(opts, ID2SYM(i_object_nl)); if (RTEST(tmp)) { Check_Type(tmp, T_STRING); state->object_nl = tmp; } tmp = ID2SYM(i_check_circular); if (st_lookup(RHASH_TBL(opts), tmp, 0)) { tmp = rb_hash_aref(opts, ID2SYM(i_check_circular)); state->check_circular = RTEST(tmp); } else { state->check_circular = 1; } tmp = ID2SYM(i_max_nesting); state->max_nesting = 19; if (st_lookup(RHASH_TBL(opts), tmp, 0)) { VALUE max_nesting = rb_hash_aref(opts, tmp); if (RTEST(max_nesting)) { Check_Type(max_nesting, T_FIXNUM); state->max_nesting = FIX2LONG(max_nesting); } else { state->max_nesting = 0; } } tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan)); state->allow_nan = RTEST(tmp); return self; }