class Rubydex::Query
Public Class Methods
static VALUE rdxr_query_parse(VALUE klass, VALUE query) {
Check_Type(query, T_STRING);
struct CParseResult result = rdx_cypher_parse(StringValueCStr(query));
if (result.error != NULL) {
VALUE message = rb_utf8_str_new_cstr(result.error);
free_c_string(result.error);
rb_raise(rb_eArgError, "%s", StringValueCStr(message));
}
return TypedData_Wrap_Struct(klass, &query_type, result.query);
}
Parses a Cypher query into an opaque, reusable object without needing a graph. Raises ArgumentError on a syntax error, so a query can be validated before building a graph.
static VALUE rdxr_cypher_schema(int argc, VALUE *argv, VALUE self) {
VALUE format;
rb_scan_args(argc, argv, "01", &format);
const char *output = rdx_cypher_schema(rdxi_symbol_or_string_cstr(format, "table"));
VALUE result = output == NULL ? rb_utf8_str_new_cstr("") : rb_utf8_str_new_cstr(output);
if (output != NULL) {
free_c_string(output);
}
return result;
}
Returns a description of the queryable Cypher schema. format may be :table (default) or :json. The schema is static, so it does not require a graph.
Public Instance Methods
static VALUE rdxr_query_render(int argc, VALUE *argv, VALUE self) {
VALUE graph_obj, format;
rb_scan_args(argc, argv, "11", &graph_obj, &format);
void *query;
TypedData_Get_Struct(self, void *, &query_type, query);
void *graph;
TypedData_Get_Struct(graph_obj, void *, &graph_type, graph);
struct CQueryResult result = rdx_query_run(query, graph, rdxi_symbol_or_string_cstr(format, "table"));
if (result.error != NULL) {
VALUE message = rb_utf8_str_new_cstr(result.error);
free_c_string(result.error);
rb_raise(rb_eArgError, "%s", StringValueCStr(message));
}
VALUE output = result.output == NULL ? rb_utf8_str_new_cstr("") : rb_utf8_str_new_cstr(result.output);
if (result.output != NULL) {
free_c_string(result.output);
}
return output;
}
Runs this parsed query against graph and returns the formatted output. format may be :table (default) or :json. Raises ArgumentError on an execution or format error.