Class: Rubydex::Document

Inherits:
Object
  • Object
show all
Defined in:
ext/rubydex/document.c

Instance Method Summary collapse

Constructor Details

#initializeObject

Instance Method Details

#definitionsObject

Returns an enumerator that yields all definitions for this document lazily



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'ext/rubydex/document.c', line 71

static VALUE rdxr_document_definitions(VALUE self) {
    if (!rb_block_given_p()) {
        return rb_enumeratorize_with_size(self, rb_str_new2("definitions"), 0, NULL, document_definitions_size);
    }

    HandleData *data;
    TypedData_Get_Struct(self, HandleData, &handle_type, data);

    void *graph;
    TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
    void *iter = rdx_document_definitions_iter_new(graph, data->id);
    VALUE args = rb_ary_new_from_args(2, self, ULL2NUM((uintptr_t)iter));
    rb_ensure(document_definitions_yield, args, document_definitions_ensure, args);

    return self;
}

#uriObject

Document#uri -> String



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'ext/rubydex/document.c', line 10

static VALUE rdxr_document_uri(VALUE self) {
    HandleData *data;
    TypedData_Get_Struct(self, HandleData, &handle_type, data);

    void *graph;
    TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
    const char *uri = rdx_document_uri(graph, data->id);

    if (uri == NULL) {
        return Qnil;
    }

    VALUE str = rb_utf8_str_new_cstr(uri);
    free_c_string(uri);

    return str;
}