Class: YAML::Syck::Scalar

Inherits:
Node
  • Object
show all
Defined in:
rubyext.c

Instance Method Summary collapse

Constructor Details

#initializeObject

YAML::Syck::Scalar.initialize



# File 'rubyext.c'

/*
 * YAML::Syck::Scalar.initialize
 */
VALUE
syck_scalar_initialize( self, type_id, val, style )
    VALUE self, type_id, val, style;
{
    rb_iv_set( self, "@kind", sym_scalar );
    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;
}

Instance Method Details

#style=Object

YAML::Syck::Scalar.style=



# File 'rubyext.c'

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

    if ( NIL_P( style ) )
    {
        node->data.str->style = scalar_none;
    } 
    else if ( style == sym_1quote )
    {
        node->data.str->style = scalar_1quote;
    } 
    else if ( style == sym_2quote )
    {
        node->data.str->style = scalar_2quote;
    } 
    else if ( style == sym_fold )
    {
        node->data.str->style = scalar_fold;
    } 
    else if ( style == sym_literal )
    {
        node->data.str->style = scalar_literal;
    } 
    else if ( style == sym_plain )
    {
        node->data.str->style = scalar_plain;
    }

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

#value=Object

YAML::Syck::Scalar.value=



# File 'rubyext.c'

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

    StringValue( val );
    node->data.str->ptr = syck_strndup( RSTRING(val)->ptr, RSTRING(val)->len );
    node->data.str->len = RSTRING(val)->len;
    node->data.str->style = scalar_none;

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