Class: Object::Syck::Map
Instance Method Summary collapse
-
#add ⇒ Object
YAML::Syck::Map.add.
-
#initialize ⇒ Object
constructor
YAML::Syck::Map.initialize.
-
#style= ⇒ Object
YAML::Syck::Map.style=.
-
#value= ⇒ Object
YAML::Syck::Map.value=.
Constructor Details
#initialize ⇒ Object
YAML::Syck::Map.initialize
1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 |
# File 'rubyext.c', line 1620
VALUE
syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
if ( !NIL_P( val ) )
{
VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
VALUE keys;
int i;
if ( NIL_P(hsh) )
{
rb_raise( rb_eTypeError, "wrong argument type" );
}
keys = rb_funcall( hsh, s_keys, 0 );
for ( i = 0; i < RARRAY_LEN(keys); i++ )
{
VALUE key = rb_ary_entry(keys, i);
syck_map_add( node, key, rb_hash_aref(hsh, key) );
}
}
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 ⇒ Object
YAML::Syck::Map.add
1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 |
# File 'rubyext.c', line 1686
VALUE
syck_map_add_m(VALUE self, VALUE key, VALUE val)
{
SyckNode *node;
VALUE emitter = rb_ivar_get( self, s_emitter );
Data_Get_Struct( self, SyckNode, node );
if ( rb_respond_to( emitter, s_node_export ) ) {
key = rb_funcall( emitter, s_node_export, 1, key );
val = rb_funcall( emitter, s_node_export, 1, val );
}
syck_map_add( node, key, val );
rb_hash_aset( rb_ivar_get( self, s_value ), key, val );
return self;
}
|
#style= ⇒ Object
YAML::Syck::Map.style=
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 |
# File 'rubyext.c', line 1706
VALUE
syck_map_style_set(VALUE self, VALUE style)
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
if ( style == sym_inline )
{
node->data.pairs->style = map_inline;
}
else
{
node->data.pairs->style = map_none;
}
rb_iv_set( self, "@style", style );
return self;
}
|
#value= ⇒ Object
YAML::Syck::Map.value=
1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 |
# File 'rubyext.c', line 1654
VALUE
syck_map_value_set(VALUE self, VALUE val)
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
if ( !NIL_P( val ) )
{
VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
VALUE keys;
int i;
if ( NIL_P(hsh) )
{
rb_raise( rb_eTypeError, "wrong argument type" );
}
syck_map_empty( node );
keys = rb_funcall( hsh, s_keys, 0 );
for ( i = 0; i < RARRAY_LEN(keys); i++ )
{
VALUE key = rb_ary_entry(keys, i);
syck_map_add( node, key, rb_hash_aref(hsh, key) );
}
}
rb_iv_set( self, "@value", val );
return val;
}
|