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



1540
1541
1542
1543
1544
1545
1546
1547
1548
# File 'ext/syck/rubyext.c', line 1540

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=



1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
# File 'ext/syck/rubyext.c', line 1553

VALUE
syck_scalar_style_set(VALUE self, VALUE style)
{
    SyckNode *node;
    TypedData_Get_Struct( self, SyckNode, &syck_node_type, 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=



1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
# File 'ext/syck/rubyext.c', line 1591

VALUE
syck_scalar_value_set(VALUE  self, VALUE val)
{
    SyckNode *node;
    TypedData_Get_Struct( self, SyckNode, &syck_node_type, 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;
}