Class: Object::Syck::Seq

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::Seq.initialize



1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
# File 'ext/syck/rubyext.c', line 1623

VALUE
syck_seq_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
{
    SyckNode *node;
    TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );

    rb_iv_set( self, "@kind", sym_seq );
    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

#add(val) ⇒ Object

YAML::Syck::Seq.add



1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
# File 'ext/syck/rubyext.c', line 1662

VALUE
syck_seq_add_m(VALUE self, VALUE val)
{
    SyckNode *node;
    VALUE emitter = rb_ivar_get( self, s_emitter );
    TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );

    if ( rb_respond_to( emitter, s_node_export ) ) {
        val = rb_funcall( emitter, s_node_export, 1, val );
    }
    syck_seq_add( node, val );
    rb_ary_push( rb_ivar_get( self, s_value ), val );

    return self;
}

#style=(style) ⇒ Object

YAML::Syck::Seq.style=



1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
# File 'ext/syck/rubyext.c', line 1681

VALUE
syck_seq_style_set(VALUE self, VALUE style)
{
    SyckNode *node;
    TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );

    if ( style == sym_inline )
    {
        node->data.list->style = seq_inline;
    }
    else
    {
        node->data.list->style = seq_none;
    }

    rb_iv_set( self, "@style", style );
    return self;
}

#value=(val) ⇒ Object

YAML::Syck::Seq.value=



1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
# File 'ext/syck/rubyext.c', line 1639

VALUE
syck_seq_value_set(VALUE self, VALUE val)
{
    SyckNode *node;
    TypedData_Get_Struct( self, SyckNode, &syck_node_type, node );

    val = rb_check_array_type( val );
    if ( !NIL_P( val ) ) {
        int i;
        syck_seq_empty( node );
        for ( i = 0; i < RARRAY_LEN( val ); i++ )
        {
            syck_seq_add( node, rb_ary_entry(val, i) );
        }
    }

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