Class: Object::Syck::Map
Instance Attribute Summary
Attributes inherited from Node
#emitter, #kind, #resolver, #type_id, #value
Instance Method Summary collapse
- #add(key, val) ⇒ Object
- #initialize(type_id, val, style) ⇒ Object constructor
- #style=(style) ⇒ Object
- #value=(val) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(type_id, val, style) ⇒ Object
1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 |
# File 'ext/syck/rubyext.c', line 1805
VALUE
syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
{
SyckNode *node;
TypedData_Get_Struct( self, SyckNode, &syck_node_type, 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(key, val) ⇒ Object
1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 |
# File 'ext/syck/rubyext.c', line 1871
VALUE
syck_map_add_m(VALUE self, VALUE key, 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 ) ) {
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=(style) ⇒ Object
1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 |
# File 'ext/syck/rubyext.c', line 1891
VALUE
syck_map_style_set(VALUE self, VALUE style)
{
SyckNode *node;
TypedData_Get_Struct( self, SyckNode, &syck_node_type, 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=(val) ⇒ Object
1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 |
# File 'ext/syck/rubyext.c', line 1839
VALUE
syck_map_value_set(VALUE self, VALUE val)
{
SyckNode *node;
TypedData_Get_Struct( self, SyckNode, &syck_node_type, 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;
}
|