Class: QuartzTorrent::TorrentDataDelegate

Inherits:
Object
  • Object
show all
Defined in:
lib/quartz_torrent/peerclient.rb

Overview

Data about torrents for use by the end user.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(torrentData, peerClientHandler) ⇒ TorrentDataDelegate

Create a new TorrentDataDelegate. This is meant to only be called internally.



130
131
132
133
134
# File 'lib/quartz_torrent/peerclient.rb', line 130

def initialize(torrentData, peerClientHandler)
  fillFrom(torrentData)
  @torrentData = torrentData
  @peerClientHandler = peerClientHandler
end

Instance Attribute Details

#alarmsObject

Array of currently raised alarms



180
181
182
# File 'lib/quartz_torrent/peerclient.rb', line 180

def alarms
  @alarms
end

#bytesDownloadedObject

Returns the value of attribute bytesDownloaded.



178
179
180
# File 'lib/quartz_torrent/peerclient.rb', line 178

def bytesDownloaded
  @bytesDownloaded
end

#bytesDownloadedDataOnlyObject

Returns the value of attribute bytesDownloadedDataOnly.



176
177
178
# File 'lib/quartz_torrent/peerclient.rb', line 176

def bytesDownloadedDataOnly
  @bytesDownloadedDataOnly
end

#bytesUploadedObject

Returns the value of attribute bytesUploaded.



177
178
179
# File 'lib/quartz_torrent/peerclient.rb', line 177

def bytesUploaded
  @bytesUploaded
end

#bytesUploadedDataOnlyObject

Returns the value of attribute bytesUploadedDataOnly.



175
176
177
# File 'lib/quartz_torrent/peerclient.rb', line 175

def bytesUploadedDataOnly
  @bytesUploadedDataOnly
end

#completedBytesObject (readonly)

Count of completed bytes of the torrent



155
156
157
# File 'lib/quartz_torrent/peerclient.rb', line 155

def completedBytes
  @completedBytes
end

#completePieceBitfieldObject (readonly)

Bitfield representing which pieces of the torrent are completed.



162
163
164
# File 'lib/quartz_torrent/peerclient.rb', line 162

def completePieceBitfield
  @completePieceBitfield
end

#downloadRateObject (readonly)

Download rate in bytes/second



144
145
146
# File 'lib/quartz_torrent/peerclient.rb', line 144

def downloadRate
  @downloadRate
end

#downloadRateDataOnlyObject (readonly)

Download rate limit in bytes/second if a limit is set, nil otherwise



152
153
154
# File 'lib/quartz_torrent/peerclient.rb', line 152

def downloadRateDataOnly
  @downloadRateDataOnly
end

#downloadRateLimitObject (readonly)

Download rate limit in bytes/second if a limit is set, nil otherwise



148
149
150
# File 'lib/quartz_torrent/peerclient.rb', line 148

def downloadRateLimit
  @downloadRateLimit
end

#infoObject

Torrent Metainfo.info struct. This is nil if the torrent has no metadata and we haven’t downloaded it yet (i.e. a magnet link).



138
139
140
# File 'lib/quartz_torrent/peerclient.rb', line 138

def info
  @info
end

#infoHashObject

Infohash of the torrent. This is binary data.



140
141
142
# File 'lib/quartz_torrent/peerclient.rb', line 140

def infoHash
  @infoHash
end

#metainfoCompletedLengthObject (readonly)

How much of the metainfo info we have downloaded in bytes. This is only set when the state is :downloading_metainfo



166
167
168
# File 'lib/quartz_torrent/peerclient.rb', line 166

def metainfoCompletedLength
  @metainfoCompletedLength
end

#metainfoLengthObject (readonly)

Length of metainfo info in bytes. This is only set when the state is :downloading_metainfo



164
165
166
# File 'lib/quartz_torrent/peerclient.rb', line 164

def metainfoLength
  @metainfoLength
end

#pausedObject (readonly)

Whether or not the torrent is paused.



168
169
170
# File 'lib/quartz_torrent/peerclient.rb', line 168

def paused
  @paused
end

#peersObject (readonly)

Array of peers for the torrent. These include connected, disconnected, and handshaking peers



157
158
159
# File 'lib/quartz_torrent/peerclient.rb', line 157

def peers
  @peers
end

#queuedObject (readonly)

Whether or not the torrent is queued.



170
171
172
# File 'lib/quartz_torrent/peerclient.rb', line 170

def queued
  @queued
end

#ratioObject

After we have completed downloading a torrent, we will continue to upload until we have uploaded ratio * torrent_size bytes. If nil, no limit on upload.



173
174
175
# File 'lib/quartz_torrent/peerclient.rb', line 173

def ratio
  @ratio
end

#recommendedNameObject

Recommended display name for this torrent.



142
143
144
# File 'lib/quartz_torrent/peerclient.rb', line 142

def recommendedName
  @recommendedName
end

#stateObject (readonly)

State of the torrent. This may be one of :downloading_metainfo, :error, :checking_pieces, :running, :downloading_metainfo, or :deleted. The :deleted state indicates that the torrent that this TorrentDataDelegate refers to is no longer being managed by the peer client.



160
161
162
# File 'lib/quartz_torrent/peerclient.rb', line 160

def state
  @state
end

#uploadDurationObject

Returns the value of attribute uploadDuration.



174
175
176
# File 'lib/quartz_torrent/peerclient.rb', line 174

def uploadDuration
  @uploadDuration
end

#uploadRateObject (readonly)

Upload rate in bytes/second



146
147
148
# File 'lib/quartz_torrent/peerclient.rb', line 146

def uploadRate
  @uploadRate
end

#uploadRateDataOnlyObject (readonly)

Returns the value of attribute uploadRateDataOnly.



153
154
155
# File 'lib/quartz_torrent/peerclient.rb', line 153

def uploadRateDataOnly
  @uploadRateDataOnly
end

#uploadRateLimitObject (readonly)

Upload rate limit in bytes/second if a limit is set, nil otherwise



150
151
152
# File 'lib/quartz_torrent/peerclient.rb', line 150

def uploadRateLimit
  @uploadRateLimit
end

Instance Method Details

#internalRefreshObject

Set the fields of this TorrentDataDelegate from the passed torrentData. This is meant to only be called internally.



190
191
192
# File 'lib/quartz_torrent/peerclient.rb', line 190

def internalRefresh
  fillFrom(@torrentData)
end

#refreshObject

Update the data in this TorrentDataDelegate from the torrentData object that it was created from. TODO: What if that torrentData is now gone?



184
185
186
# File 'lib/quartz_torrent/peerclient.rb', line 184

def refresh
  @peerClientHandler.updateDelegateTorrentData self
end