Class: Object::Syck::Parser
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#bufsize ⇒ Object
YAML::Syck::Parser.bufsize => Integer.
-
#bufsize= ⇒ Object
YAML::Syck::Parser.bufsize = Integer.
-
#initialize ⇒ Object
constructor
YAML::Syck::Parser.initialize( resolver, options ).
-
#load ⇒ Object
YAML::Syck::Parser.load( IO or String ).
-
#load_documents ⇒ Object
YAML::Syck::Parser.load_documents( IO or String ) { |doc| }.
-
#set_resolver ⇒ Object
YAML::Syck::Parser#set_resolver.
Constructor Details
#initialize ⇒ Object
YAML::Syck::Parser.initialize( resolver, options )
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
# File 'rubyext.c', line 798
static VALUE
syck_parser_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE options;
if (rb_scan_args(argc, argv, "01", &options) == 0)
{
options = rb_hash_new();
}
else
{
Check_Type(options, T_HASH);
}
rb_ivar_set(self, s_options, options);
rb_ivar_set(self, s_input, Qnil);
return self;
}
|
Instance Method Details
#bufsize ⇒ Object
YAML::Syck::Parser.bufsize => Integer
834 835 836 837 838 839 840 841 |
# File 'rubyext.c', line 834
static VALUE
syck_parser_bufsize_get(VALUE self)
{
SyckParser *parser;
Data_Get_Struct(self, SyckParser, parser);
return INT2FIX( parser->bufsize );
}
|
#bufsize= ⇒ Object
YAML::Syck::Parser.bufsize = Integer
818 819 820 821 822 823 824 825 826 827 828 829 |
# File 'rubyext.c', line 818
static VALUE
syck_parser_bufsize_set(VALUE self, VALUE size)
{
SyckParser *parser;
if ( rb_respond_to( size, s_to_i ) ) {
int n = NUM2INT(rb_funcall(size, s_to_i, 0));
Data_Get_Struct(self, SyckParser, parser);
parser->bufsize = n;
}
return self;
}
|
#load ⇒ Object
YAML::Syck::Parser.load( IO or String )
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 |
# File 'rubyext.c', line 846
VALUE
syck_parser_load(int argc, VALUE *argv, VALUE self)
{
VALUE port, proc, model, input;
SyckParser *parser;
struct parser_xtra *bonus;
rb_scan_args(argc, argv, "11", &port, &proc);
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
Data_Get_Struct(self, SyckParser, parser);
syck_set_model( self, input, model );
bonus = (struct parser_xtra *)parser->bonus;
bonus->taint = syck_parser_assign_io(parser, &port);
bonus->data = rb_hash_new();
bonus->resolver = rb_attr_get( self, s_resolver );
if ( NIL_P( proc ) ) bonus->proc = 0;
else bonus->proc = proc;
return syck_parse( parser );
}
|
#load_documents ⇒ Object
YAML::Syck::Parser.load_documents( IO or String ) { |doc| }
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
# File 'rubyext.c', line 873
VALUE
syck_parser_load_documents(int argc, VALUE *argv, VALUE self)
{
VALUE port, proc, v, input, model;
SyckParser *parser;
struct parser_xtra *bonus;
rb_scan_args(argc, argv, "1&", &port, &proc);
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
Data_Get_Struct(self, SyckParser, parser);
syck_set_model( self, input, model );
bonus = (struct parser_xtra *)parser->bonus;
bonus->taint = syck_parser_assign_io(parser, &port);
bonus->resolver = rb_attr_get( self, s_resolver );
bonus->proc = 0;
while ( 1 )
{
/* Reset hash for tracking nodes */
bonus->data = rb_hash_new();
/* Parse a document */
v = syck_parse( parser );
if ( parser->eof == 1 )
{
break;
}
/* Pass document to block */
rb_funcall( proc, s_call, 1, v );
}
return Qnil;
}
|
#set_resolver ⇒ Object
YAML::Syck::Parser#set_resolver
914 915 916 917 918 919 |
# File 'rubyext.c', line 914
VALUE
syck_parser_set_resolver(VALUE self, VALUE resolver)
{
rb_ivar_set( self, s_resolver, resolver );
return self;
}
|