Module: UriParser

Defined in:
lib/uriparser.rb,
lib/uriparser/version.rb,
ext/uriparser_ext/uriparser.c

Overview

:nodoc: all

Defined Under Namespace

Classes: URI

Constant Summary collapse

VERSION =
'0.2.1'

Class Method Summary collapse

Class Method Details

.parse(uri_obj) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'ext/uriparser_ext/uriparser.c', line 132

static VALUE
rb_uriparser_s_parse(VALUE klass, VALUE uri_obj)
{
    char *str_uri = StringValueCStr(uri_obj);
    UriUriA *uri = ALLOC(UriUriA);
    struct uri_data *data;
    VALUE generic_uri;

    generic_uri = rb_class_new_instance(0, NULL, rb_cUri_Class);
    Data_Get_Struct(generic_uri, struct uri_data, data);

    data->uri = uri;

    if( parse_uri(str_uri, uri) != URI_SUCCESS ) {
        rb_raise(rb_eUriInvalidURIError, "unable to parse the URI: %s", str_uri);
    }

    return generic_uri;
}