class Object::Syck::Scalar - syck-1.0.5 Documentation

# class Object::Syck::Scalar

Define YAML::Syck::Scalar, YAML::Syck::Seq, YAML::Syck::Map –

    all are the publicly usable variants of YAML::Syck::Node

### Public Class Methods

new(p1, p2, p3) click to toggle source

YAML::Syck::Scalar.initialize

    VALUE
    syck_scalar_initialize(VALUE self, VALUE type_id, VALUE val, VALUE 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;
    }

### Public Instance Methods

style=(p1) click to toggle source

YAML::Syck::Scalar.style=

    VALUE
    syck_scalar_style_set(VALUE self, VALUE 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=(p1) click to toggle source

YAML::Syck::Scalar.value=

    VALUE
    syck_scalar_value_set(VALUE  self, VALUE val)
    {
        SyckNode *node;
        Data_Get_Struct( self, SyckNode, node );

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

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