sfml3.rb

Class: SFML::FtpListingResponse

Inherits:
Object
  • Object
show all
Defined in:
ext/network/ftp.c,
ext/network/ftp.c

Overview

An FtpResponse specialization returned by Ftp#directory_listing, additionally carrying the list of filenames.

Instance Method Summary collapse

Instance Method Details

#count ⇒ Integer

Returns the number of filenames in the listing.

Returns:

  • (Integer)

Returns:

  • (Integer) —

    the number of filenames in the listing



546
547
548
# File 'ext/network/ftp.c', line 546

static VALUE FtpListingResponse_count(VALUE self) {
    return SIZET2NUM(sfFtpListingResponse_getCount(Get_FtpListingResponse_Struct(self)));
}

#message ⇒ String

Returns the message sent by the server.

Returns:

  • (String)

Returns:

  • (String) —

    the full response message sent by the server



536
537
538
# File 'ext/network/ftp.c', line 536

static VALUE FtpListingResponse_message(VALUE self) {
    return rb_str_new_cstr(sfFtpListingResponse_getMessage(Get_FtpListingResponse_Struct(self)));
}

#name(index) ⇒ String

Returns the filename stored at index in the listing.

Returns:

  • (String)

Returns:

  • (String) —

    the filename at index in the listing

Raises:

  • (IndexError) —

    if index is out of range



558
559
560
561
562
563
564
565
566
567
568
# File 'ext/network/ftp.c', line 558

static VALUE FtpListingResponse_name(VALUE self, VALUE rb_index) {
    void* response = Get_FtpListingResponse_Struct(self);
    size_t index = (size_t)NUM2SIZET(rb_index);
    size_t count = sfFtpListingResponse_getCount(response);

    if (index >= count) {
        rb_raise(rb_eIndexError, "index %zu outside of listing size %zu", index, count);
    }

    return rb_str_new_cstr(sfFtpListingResponse_getName(response, index));
}

#ok? ⇒ Boolean

Returns true if the server reported success.

Returns:

  • (Boolean)

Returns:

  • (Boolean) —

    whether the status is a "success" code (< 400)



505
506
507
# File 'ext/network/ftp.c', line 505

static VALUE FtpListingResponse_ok(VALUE self) {
    return BOOL2RB(sfFtpListingResponse_isOk(Get_FtpListingResponse_Struct(self)));
}

#status ⇒ Integer

Returns the raw status code reported by the server.

Returns:

  • (Integer)

Returns:

  • (Integer) —

    the raw FTP status code



515
516
517
# File 'ext/network/ftp.c', line 515

static VALUE FtpListingResponse_status(VALUE self) {
    return INT2NUM(sfFtpListingResponse_getStatus(Get_FtpListingResponse_Struct(self)));
}

#status_name ⇒ Symbol

Returns the status as an FtpStatus name.

Returns:

  • (Symbol)

Returns:

  • (Symbol) —

    an FtpStatus name for #status



525
526
527
528
# File 'ext/network/ftp.c', line 525

static VALUE FtpListingResponse_status_name(VALUE self) {
    return ID2SYM(rb_intern(
        ftp_status_name(sfFtpListingResponse_getStatus(Get_FtpListingResponse_Struct(self)))));
}