Class: Transmission::Torrent::Stat

Inherits:
Object
  • Object
show all
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

Instance Method Details

#down_peersInteger

Returns a number of downloaded peers.

Returns:

  • (Integer)


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_rateFloat

Returns downloading rate.

Returns:

  • (Float)


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);
}

#downloadedInteger

Returns the total number of downloaded bytes.

Returns:

  • (Integer)


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);
}

#errorInteger

Returns the error code of the torrent, 0 otherwise.

Returns:

  • (Integer)


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_nameObject



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

#etaInteger

Returns eta until the torrent finishes downloading.

Returns:

  • (Integer)


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);
}

#leechersInteger

Returns a number of leechers.

Returns:

  • (Integer)


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);
}

#peersArray

Returns an array of numbers of downloading and uploading peers.

Returns:

  • (Array)


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_totalInteger

Returns the total number of peers.

Returns:

  • (Integer)


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);
}

#progressFloat

Returns the progress of the torrent from 0.0 to 1.0.

Returns:

  • (Float)


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);
}

#ratesArray

Returns an array of downloading and uploading rates.

Returns:

  • (Array)


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));
}

#seedersInteger

Returns a number of seeders.

Returns:

  • (Integer)


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);
}

#statusInteger

Returns the status of the torrent.

Returns:

  • (Integer)


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_nameObject



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_sObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/transmission.rb', line 57

def to_s
  format =<<-EOS
Status: %s, Error: %d
Progress: %.1f, Rate: Down/Up %.1fKb/%.1fKb, ETA: %d
Peers Total: %d, Downloading: %d, Uploading: %d
Seeders: %d, Leechers: %d\nDownloaded: %d, Uploaded: %d
EOS
  format % [status_name, error, progress, rates, eta, peers_total, 
            peers, seeders, leechers, downloaded, uploaded].flatten
end

#tracker_errorString

Returns the tracker error or empty string.

Returns:

  • (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_peersInteger

Returns a number of uploading peers.

Returns:

  • (Integer)


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_rateFloat

Returns uploading rate.

Returns:

  • (Float)


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);
}

#uploadedInteger

Returns the total number of uploaded bytes.

Returns:

  • (Integer)


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);
}