Class | YAML::Syck::Parser
In: | syck/rubyext.c
Parent: | Object

### Methods

bufsize bufsize= load load_documents new set_resolver

### Public Class methods

new(...)

YAML::Syck::Parser.initialize( resolver, options )

[Source]

    /*
     * YAML::Syck::Parser.initialize( resolver, options )
     */
    static VALUE
    syck_parser_initialize(argc, argv, self)
        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);
        return self;
    }

### Public Instance methods

bufsize()

YAML::Syck::Parser.bufsize => Integer

[Source]

    /*
     * YAML::Syck::Parser.bufsize => Integer
     */
    static VALUE
    syck_parser_bufsize_get( self )
        VALUE self;
    {
        SyckParser *parser;

        Data_Get_Struct(self, SyckParser, parser);
        return INT2FIX( parser->bufsize );
    }

bufsize=(p1)

YAML::Syck::Parser.bufsize = Integer

[Source]

    /*
     * YAML::Syck::Parser.bufsize = Integer
     */
    static VALUE
    syck_parser_bufsize_set( self, size )
        VALUE self, 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;
    }

load(...)

YAML::Syck::Parser.load( IO or String )

[Source]

    /*
     * YAML::Syck::Parser.load( IO or String )
     */
    VALUE
    syck_parser_load(argc, argv, self)
        int argc;
        VALUE *argv;
        VALUE self;
    {
        VALUE port, proc, model, input;
        SyckParser *parser;
        struct parser_xtra *bonus = S_ALLOC_N( struct parser_xtra, 1 );
        volatile VALUE hash;    /* protect from GC */

        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->taint = syck_parser_assign_io(parser, port);
        bonus->data = hash = rb_hash_new();
        bonus->resolver = rb_attr_get( self, s_resolver );
        if ( NIL_P( proc ) ) bonus->proc = 0;
        else                 bonus->proc = proc;

        parser->bonus = (void *)bonus;

        return syck_parse( parser );
    }

load_documents(...)

YAML::Syck::Parser.load_documents( IO or String ) { |doc| }

[Source]

    /*
     * YAML::Syck::Parser.load_documents( IO or String ) { |doc| }
     */
    VALUE
    syck_parser_load_documents(argc, argv, self)
        int argc;
        VALUE *argv;
        VALUE self;
    {
        VALUE port, proc, v, input, model;
        SyckParser *parser;
        struct parser_xtra *bonus = S_ALLOC_N( struct parser_xtra, 1 );
        volatile VALUE hash;

        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->taint = syck_parser_assign_io(parser, port);
        bonus->resolver = rb_attr_get( self, s_resolver );
        bonus->proc = 0;
        parser->bonus = (void *)bonus;

        while ( 1 )
        {
            /* Reset hash for tracking nodes */
            bonus->data = hash = 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;
    }

set_resolver(p1)

YAML::Syck::Parser#set_resolver

[Source]

    /*
     * YAML::Syck::Parser#set_resolver
     */
    VALUE
    syck_parser_set_resolver( self, resolver )
        VALUE self, resolver;
    {
        rb_ivar_set( self, s_resolver, resolver );
        return self;
    }

[Validate]