rb_cObject
Define YAML::Syck::Parser class
YAML::Syck::Parser.initialize( resolver, options )
static VALUE syck_parser_initialize(int argc, VALUE *argv, VALUE self) { VALUE options; if (rb_scan_args(argc, argv, "01", &options) == 0) { options = rb_hash_new(); } else { Check_Type(options, T_HASH); } rb_ivar_set(self, s_options, options); rb_ivar_set(self, s_input, Qnil); return self; }
YAML::Syck::Parser.bufsize => Integer
static VALUE syck_parser_bufsize_get(VALUE self) { SyckParser *parser; Data_Get_Struct(self, SyckParser, parser); return INT2FIX( parser->bufsize ); }
YAML::Syck::Parser.bufsize = Integer
static VALUE syck_parser_bufsize_set(VALUE self, VALUE size) { SyckParser *parser; if ( rb_respond_to( size, s_to_i ) ) { int n = NUM2INT(rb_funcall(size, s_to_i, 0)); Data_Get_Struct(self, SyckParser, parser); parser->bufsize = n; } return self; }
YAML::Syck::Parser.load( IO or String )
VALUE syck_parser_load(int argc, VALUE *argv, VALUE self) { VALUE port, proc, model, input; SyckParser *parser; struct parser_xtra *bonus; rb_scan_args(argc, argv, "11", &port, &proc); input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input ); model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model ); Data_Get_Struct(self, SyckParser, parser); syck_set_model( self, input, model ); bonus = (struct parser_xtra *)parser->bonus; bonus->taint = syck_parser_assign_io(parser, &port); bonus->data = rb_hash_new(); bonus->resolver = rb_attr_get( self, s_resolver ); if ( NIL_P( proc ) ) bonus->proc = 0; else bonus->proc = proc; return syck_parse( parser ); }
YAML::Syck::Parser.load_documents( IO or String ) { |doc| }
VALUE syck_parser_load_documents(int argc, VALUE *argv, VALUE self) { VALUE port, proc, v, input, model; SyckParser *parser; struct parser_xtra *bonus; rb_scan_args(argc, argv, "1&", &port, &proc); input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input ); model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model ); Data_Get_Struct(self, SyckParser, parser); syck_set_model( self, input, model ); bonus = (struct parser_xtra *)parser->bonus; bonus->taint = syck_parser_assign_io(parser, &port); bonus->resolver = rb_attr_get( self, s_resolver ); bonus->proc = 0; while ( 1 ) { /* Reset hash for tracking nodes */ bonus->data = rb_hash_new(); /* Parse a document */ v = syck_parse( parser ); if ( parser->eof == 1 ) { break; } /* Pass document to block */ rb_funcall( proc, s_call, 1, v ); } return Qnil; }
Commenting is here to help enhance the documentation. For example, sample code, or clarification of the documentation.
If you are posting code samples in your comments, please wrap them in "<pre><code class="ruby" > ... </code></pre>" markup in order to get syntax highlighting.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file a bug report so that it can be corrected for the next release. Thank you.