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;
}
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;
}
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;
}