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



1628
1629
1630
1631
1632
1633
1634
1635
1636
# File 'ext/syck/rubyext.c', line 1628

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=



1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
# File 'ext/syck/rubyext.c', line 1641

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=



1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
# File 'ext/syck/rubyext.c', line 1679

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