Class: YAML::Syck::Map

Class | YAML::Syck::Map
In: | syck/rubyext.c
Parent: | YAML::Syck::Node

### Methods

add new style= value=

### Public Class methods

new(p1, p2, p3)

YAML::Syck::Map.initialize

[Source]

    /*
     * YAML::Syck::Map.initialize
     */
    VALUE
    syck_map_initialize( self, type_id, val, style )
        VALUE self, type_id, val, style;
    {
        SyckNode *node;
        Data_Get_Struct( self, SyckNode, node );

        if ( !NIL_P( val ) )
        {
            VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
            VALUE keys;
            int i;
            if ( NIL_P(hsh) )
            {
                rb_raise( rb_eTypeError, "wrong argument type" );
            }

            keys = rb_funcall( hsh, s_keys, 0 );
            for ( i = 0; i < RARRAY(keys)->len; i++ )
            {
                VALUE key = rb_ary_entry(keys, i);
                syck_map_add( node, key, rb_hash_aref(hsh, key) );
            }
        }

        rb_iv_set( self, "@kind", sym_seq );
        rb_funcall( self, s_type_id_set, 1, type_id );
        rb_funcall( self, s_value_set, 1, val );
        rb_funcall( self, s_style_set, 1, style );
        return self;
    }

### Public Instance methods

add(p1, p2)

YAML::Syck::Map.add

[Source]

    /*
     * YAML::Syck::Map.add
     */
    VALUE
    syck_map_add_m( self, key, val )
        VALUE self, key, val;
    {
        SyckNode *node;
        VALUE emitter = rb_ivar_get( self, s_emitter );
        Data_Get_Struct( self, SyckNode, node );

        if ( rb_respond_to( emitter, s_node_export ) ) {
            key = rb_funcall( emitter, s_node_export, 1, key );
            val = rb_funcall( emitter, s_node_export, 1, val );
        }
        syck_map_add( node, key, val );
        rb_hash_aset( rb_ivar_get( self, s_value ), key, val );

        return self;
    }

style=(p1)

YAML::Syck::Map.style=

[Source]

    /*
     * YAML::Syck::Map.style=
     */
    VALUE
    syck_map_style_set( self, style )
        VALUE self, style;
    {
        SyckNode *node;
        Data_Get_Struct( self, SyckNode, node );

        if ( style == sym_inline )
        {
            node->data.pairs->style = map_inline;
        }
        else
        {
            node->data.pairs->style = map_none;
        }

        rb_iv_set( self, "@style", style );
        return self;
    }

value=(p1)

YAML::Syck::Map.value=

[Source]

    /*
     * YAML::Syck::Map.value=
     */
    VALUE
    syck_map_value_set( self, val )
        VALUE self, val;
    {
        SyckNode *node;
        Data_Get_Struct( self, SyckNode, node );

        if ( !NIL_P( val ) )
        {
            VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
            VALUE keys;
            int i;
            if ( NIL_P(hsh) )
            {
                rb_raise( rb_eTypeError, "wrong argument type" );
            }

            syck_map_empty( node );
            keys = rb_funcall( hsh, s_keys, 0 );
            for ( i = 0; i < RARRAY(keys)->len; i++ )
            {
                VALUE key = rb_ary_entry(keys, i);
                syck_map_add( node, key, rb_hash_aref(hsh, key) );
            }
        }

        rb_iv_set( self, "@value", val );
        return val;
    }

[Validate]