Class: BibTeX
- Inherits:
-
Object
- Object
- BibTeX
- Defined in:
- lib/btparse-ruby/BibTeX.rb,
ext/btparse-ruby/btparse_ruby.c
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Class Method Summary collapse
- .parse(rb_entry_text) ⇒ Object
- .parse_author(rb_string) ⇒ Object
- .parse_file(rb_filename) ⇒ Object
- .purify(rb_string) ⇒ Object
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
2 3 4 |
# File 'lib/btparse-ruby/BibTeX.rb', line 2 def entries @entries end |
Class Method Details
.parse(rb_entry_text) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'ext/btparse-ruby/btparse_ruby.c', line 62 static VALUE bibtex_parse(VALUE klass, VALUE rb_entry_text) { Check_Type(rb_entry_text, T_STRING); char *entry_text = RSTRING_PTR(rb_entry_text); boolean status = 0; bt_initialize(); AST *entries = bt_parse_entry_s(entry_text, NULL, 1, 0, &status); /* Exit early if parsing failed */ if (entries == NULL || status == 0) { return Qnil; } VALUE rb_entries = ast_to_class(entries); bt_parse_entry_s(NULL, NULL, 1, 0, NULL); bt_cleanup(); return rb_entries; } |
.parse_author(rb_string) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'ext/btparse-ruby/btparse_ruby.c', line 113 static VALUE (VALUE klass, VALUE rb_string) { Check_Type(rb_string, T_STRING); bt_initialize(); bt_stringlist * = bt_split_list(RSTRING_PTR(rb_string), "and", NULL, 1, "authors"); VALUE = rb_ary_new(); for (int i = 0; i < ->num_items; i++) { char * = ->items[i]; VALUE = rb_str_new2(); rb_ary_push(, ); } bt_free_list(); bt_cleanup(); return ; } |
.parse_file(rb_filename) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'ext/btparse-ruby/btparse_ruby.c', line 88 static VALUE bibtex_parse_file(VALUE klass, VALUE rb_filename) { Check_Type(rb_filename, T_STRING); char *filename = RSTRING_PTR(rb_filename); boolean status = 0; bt_initialize(); AST *entries = bt_parse_file(filename, 0, &status); /* Exit early if parsing failed */ if (entries == NULL || status == 0) { return Qnil; } VALUE rb_entries = ast_to_class(entries); bt_cleanup(); return rb_entries; } |
.purify(rb_string) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'ext/btparse-ruby/btparse_ruby.c', line 138 static VALUE bibtex_purify(VALUE klass, VALUE rb_string) { Check_Type(rb_string, T_STRING); bt_initialize(); char *string = malloc(RSTRING_LEN(rb_string) + 1); strcpy(string, RSTRING_PTR(rb_string)); bt_purify_string(string, 0); bt_cleanup(); return rb_str_new2(string); } |