Class: UriParser::URI
- Inherits:
-
Object
- Object
- UriParser::URI
- Defined in:
- lib/uriparser.rb,
ext/uriparser_ext/uriparser.c
Instance Method Summary collapse
- #escape ⇒ Object
- #fragment ⇒ Object
- #fragment= ⇒ Object
- #host ⇒ Object
- #host= ⇒ Object
- #initialize ⇒ Object constructor
-
#normalize! ⇒ Object
TODO: Include option mask.
- #password ⇒ Object
- #path ⇒ Object
- #path= ⇒ Object
- #port ⇒ Object
- #port=(value) ⇒ Object
- #query ⇒ Object
- #query= ⇒ Object
- #scheme ⇒ Object
- #scheme= ⇒ Object
- #str_port ⇒ Object
- #str_port= ⇒ Object
- #to_s ⇒ Object
- #unescape ⇒ Object
- #user ⇒ Object
- #userinfo ⇒ Object
- #userinfo= ⇒ Object
Constructor Details
#initialize ⇒ Object
152 153 154 155 156 |
# File 'ext/uriparser_ext/uriparser.c', line 152
static VALUE
rb_uriparser_initialize(VALUE self)
{
return self;
}
|
Instance Method Details
#escape ⇒ Object
219 220 221 222 223 |
# File 'ext/uriparser_ext/uriparser.c', line 219
static VALUE
rb_uriparser_escape(VALUE self)
{
return Qnil;
}
|
#fragment ⇒ Object
#fragment= ⇒ Object
#host ⇒ Object
#host= ⇒ Object
#normalize! ⇒ Object
TODO: Include option mask
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'ext/uriparser_ext/uriparser.c', line 202
static VALUE
rb_uriparser_normalize_bang(VALUE self)
{
struct uri_data *data;
Data_Get_Struct(self, struct uri_data, data);
update_uri(self);
if( uriNormalizeSyntaxA(data->uri) != URI_SUCCESS ) {
rb_raise(rb_eError, "unable to normalize the URI");
}
/* Invalidate any previous field value */
reset_fields(data);
return self;
}
|
#password ⇒ Object
23 24 25 26 27 |
# File 'lib/uriparser.rb', line 23 def password return unless userinfo userinfo.split(':')[1] end |
#path ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'ext/uriparser_ext/uriparser.c', line 166
static VALUE
rb_uriparser_get_path(VALUE self)
{
struct uri_data *data;
/* lazy load */
Data_Get_Struct(self, struct uri_data, data);
if( RB_TYPE_P(data->path, T_UNDEF) ) {
if( data->uri ) {
if( data->uri->pathHead ) {
/* starts with slash */
UriPathSegmentA *path_segment = data->uri->pathHead;
data->path = rb_str_new("/", 1);
do { /* go through the linked list */
rb_str_cat(
data->path, path_segment->text.first,
path_segment->text.afterLast
- path_segment->text.first
+ (*path_segment->text.afterLast == '/')
); /* check if there is a slash to add */
path_segment = path_segment->next;
} while( path_segment );
}
else {
data->path = rb_str_new("", 0);
}
}
else {
data->path = Qnil;
}
}
return data->path;
}
|
#path= ⇒ Object
#port ⇒ Object
8 9 10 |
# File 'lib/uriparser.rb', line 8 def port @port ||= str_port.nil? ? nil : str_port.to_i end |
#port=(value) ⇒ Object
12 13 14 15 |
# File 'lib/uriparser.rb', line 12 def port=(value) @port = value.to_i self.str_port = (value.nil? ? nil : value.to_s) end |
#query ⇒ Object
#query= ⇒ Object
#scheme ⇒ Object
#scheme= ⇒ Object
#str_port ⇒ Object
#str_port= ⇒ Object
#to_s ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'ext/uriparser_ext/uriparser.c', line 231
static VALUE
rb_uriparser_to_s(VALUE self)
{
int chars_required;
char *str_uri;
UriUriA *uri = update_uri(self);
VALUE obj_str_uri;
if(
uriToStringCharsRequiredA(uri, &chars_required) != URI_SUCCESS
|| !(str_uri = ALLOC_N(char, ++chars_required))
|| uriToStringA(str_uri, uri, chars_required, NULL) != URI_SUCCESS
) {
rb_raise(rb_eError, "unable to convert to string");
}
obj_str_uri = rb_str_new2(str_uri);
xfree(str_uri);
return obj_str_uri;
}
|
#unescape ⇒ Object
225 226 227 228 229 |
# File 'ext/uriparser_ext/uriparser.c', line 225
static VALUE
rb_uriparser_unescape(VALUE self)
{
return Qnil;
}
|
#user ⇒ Object
17 18 19 20 21 |
# File 'lib/uriparser.rb', line 17 def user return unless userinfo userinfo.split(':').first end |