Class: Transmission::Torrent::Stat
- Inherits:
-
Object
- Object
- Transmission::Torrent::Stat
- Defined in:
- ext/r_transmission.c,
lib/transmission.rb,
ext/r_transmission.c
Overview
Summary
The Stat class containts the information about the torrent.
Constant Summary collapse
- STATUS_CHECK =
INT2FIX(TR_STATUS_CHECK)
- STATUS_DOWNLOAD =
INT2FIX(TR_STATUS_DOWNLOAD)
- STATUS_SEED =
INT2FIX(TR_STATUS_SEED)
- STATUS_STOPPING =
INT2FIX(TR_STATUS_STOPPING)
- STATUS_STOPPED =
INT2FIX(TR_STATUS_STOPPED)
- STATUS_PAUSE =
INT2FIX(TR_STATUS_PAUSE)
- STATUS_ACTIVE =
INT2FIX(TR_STATUS_ACTIVE)
- STATUS_INACTIVE =
INT2FIX(TR_STATUS_INACTIVE)
- ERR_TRACKER =
INT2FIX(TR_ETRACKER)
- ERR_INOUT =
INT2FIX(TR_EINOUT)
Instance Method Summary collapse
-
#down_peers ⇒ Integer
Returns a number of downloaded peers.
-
#down_rate ⇒ Float
Returns downloading rate.
-
#downloaded ⇒ Integer
Returns the total number of downloaded bytes.
-
#error ⇒ Integer
Returns the error code of the torrent, 0 otherwise.
- #error_name ⇒ Object
-
#eta ⇒ Integer
Returns eta until the torrent finishes downloading.
-
#leechers ⇒ Integer
Returns a number of leechers.
-
#peers ⇒ Array
Returns an array of numbers of downloading and uploading peers.
-
#peers_total ⇒ Integer
Returns the total number of peers.
-
#progress ⇒ Float
Returns the progress of the torrent from 0.0 to 1.0.
-
#rates ⇒ Array
Returns an array of downloading and uploading rates.
-
#seeders ⇒ Integer
Returns a number of seeders.
-
#status ⇒ Integer
Returns the status of the torrent.
- #status_name ⇒ Object
- #to_s ⇒ Object
-
#tracker_error ⇒ String
Returns the tracker error or empty string.
-
#up_peers ⇒ Integer
Returns a number of uploading peers.
-
#up_rate ⇒ Float
Returns uploading rate.
-
#uploaded ⇒ Integer
Returns the total number of uploaded bytes.
Instance Method Details
#down_peers ⇒ Integer
Returns a number of downloaded peers.
920 921 922 923 924 925 926 |
# File 'ext/r_transmission.c', line 920 static VALUE r_stat_down_peers(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->peersDownloading); } |
#down_rate ⇒ Float
Returns downloading rate.
836 837 838 839 840 841 842 |
# File 'ext/r_transmission.c', line 836 static VALUE r_stat_down_rate(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return rb_float_new(stat->rateDownload); } |
#downloaded ⇒ Integer
Returns the total number of downloaded bytes.
976 977 978 979 980 981 982 |
# File 'ext/r_transmission.c', line 976 static VALUE r_stat_downloaded(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return ULONG2NUM(stat->downloaded); } |
#error ⇒ Integer
Returns the error code of the torrent, 0 otherwise.
794 795 796 797 798 799 800 |
# File 'ext/r_transmission.c', line 794 static VALUE r_stat_error(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->error); } |
#error_name ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/transmission.rb', line 46 def error_name case error when ERR_TRACKER "Tracker: #{tracker_error}" when ERR_INOUT "Input/Output" else "Unknown" end end |
#eta ⇒ Integer
Returns eta until the torrent finishes downloading.
878 879 880 881 882 883 884 |
# File 'ext/r_transmission.c', line 878 static VALUE r_stat_eta(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->eta); } |
#leechers ⇒ Integer
Returns a number of leechers.
962 963 964 965 966 967 968 |
# File 'ext/r_transmission.c', line 962 static VALUE r_stat_leechers(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->leechers); } |
#peers ⇒ Array
Returns an array of numbers of downloading and uploading peers.
934 935 936 937 938 939 940 |
# File 'ext/r_transmission.c', line 934 static VALUE r_stat_peers(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return rb_ary_new3(2, INT2FIX(stat->peersDownloading), INT2FIX(stat->peersUploading)); } |
#peers_total ⇒ Integer
Returns the total number of peers.
892 893 894 895 896 897 898 |
# File 'ext/r_transmission.c', line 892 static VALUE r_stat_peers_total(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->peersTotal); } |
#progress ⇒ Float
Returns the progress of the torrent from 0.0 to 1.0.
822 823 824 825 826 827 828 |
# File 'ext/r_transmission.c', line 822 static VALUE r_stat_progress(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return rb_float_new(stat->progress); } |
#rates ⇒ Array
Returns an array of downloading and uploading rates.
864 865 866 867 868 869 870 |
# File 'ext/r_transmission.c', line 864 static VALUE r_stat_rates(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return rb_ary_new3(2, rb_float_new(stat->rateDownload), rb_float_new(stat->rateUpload)); } |
#seeders ⇒ Integer
Returns a number of seeders.
948 949 950 951 952 953 954 |
# File 'ext/r_transmission.c', line 948 static VALUE r_stat_seeders(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->seeders); } |
#status ⇒ Integer
Returns the status of the torrent.
780 781 782 783 784 785 786 |
# File 'ext/r_transmission.c', line 780 static VALUE r_stat_status(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->status); } |
#status_name ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/transmission.rb', line 27 def status_name case status when STATUS_CHECK "Checking" when STATUS_DOWNLOAD "Downloading" when STATUS_SEED "Seeding" when STATUS_STOPPING "Stopping" when STATUS_STOPPED "Stopped" when STATUS_PAUSE "Paused" else "Unknown" end end |
#to_s ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/transmission.rb', line 57 def to_s format ="Status: %s, Error: %d\nProgress: %.1f, Rate: Down/Up %.1fKb/%.1fKb, ETA: %d\nPeers Total: %d, Downloading: %d, Uploading: %d\nSeeders: %d, Leechers: %d\\nDownloaded: %d, Uploaded: %d\n" format % [status_name, error, progress, rates, eta, peers_total, peers, seeders, leechers, downloaded, uploaded].flatten end |
#tracker_error ⇒ String
Returns the tracker error or empty string.
808 809 810 811 812 813 814 |
# File 'ext/r_transmission.c', line 808 static VALUE r_stat_tracker_error(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return rb_str_new2(stat->trackerError); } |
#up_peers ⇒ Integer
Returns a number of uploading peers.
906 907 908 909 910 911 912 |
# File 'ext/r_transmission.c', line 906 static VALUE r_stat_up_peers(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return INT2FIX(stat->peersUploading); } |
#up_rate ⇒ Float
Returns uploading rate.
850 851 852 853 854 855 856 |
# File 'ext/r_transmission.c', line 850 static VALUE r_stat_up_rate(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return rb_float_new(stat->rateUpload); } |
#uploaded ⇒ Integer
Returns the total number of uploaded bytes.
990 991 992 993 994 995 996 |
# File 'ext/r_transmission.c', line 990 static VALUE r_stat_uploaded(VALUE self) { tr_stat_t *stat; Data_Get_Struct(self, tr_stat_t, stat); return ULONG2NUM(stat->uploaded); } |