Class: Object::Syck::Scalar

Inherits:
Node show all
Defined in:
ext/syck/rubyext.c

Instance Attribute Summary

Attributes inherited from Node

#emitter, #kind, #resolver, #type_id, #value

Instance Method Summary collapse

Methods inherited from Node

#transform, #type_id=

Constructor Details

#initialize(type_id, val, style) ⇒ Object

YAML::Syck::Scalar.initialize



1447
1448
1449
1450
1451
1452
1453
1454
1455
# File 'ext/syck/rubyext.c', line 1447

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

Instance Method Details

#style=(style) ⇒ Object

YAML::Syck::Scalar.style=



1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
# File 'ext/syck/rubyext.c', line 1460

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=(val) ⇒ Object

YAML::Syck::Scalar.value=



1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
# File 'ext/syck/rubyext.c', line 1498

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