Class: QuartzTorrent::BlockInfo
- Inherits:
-
Object
- Object
- QuartzTorrent::BlockInfo
- Defined in:
- lib/quartz_torrent/blockstate.rb
Overview
Information representing a single block (a part of a piece)
Instance Attribute Summary collapse
-
#blockIndex ⇒ Object
Index of the block in units of the blockSize from the BlockState that created this object.
-
#length ⇒ Object
Length of the block in bytes.
-
#offset ⇒ Object
Offset (in bytes) within the piece where the block begins.
-
#peers ⇒ Object
A list of peers that have the piece this block belongs to.
-
#pieceIndex ⇒ Object
The index of the piece that this block belongs to.
Instance Method Summary collapse
-
#getRequest ⇒ Object
Return a new Bittorrent Request message that requests this block.
-
#initialize(pieceIndex, offset, length, peers, blockIndex) ⇒ BlockInfo
constructor
A new instance of BlockInfo.
Constructor Details
#initialize(pieceIndex, offset, length, peers, blockIndex) ⇒ BlockInfo
Returns a new instance of BlockInfo.
8 9 10 11 12 13 14 |
# File 'lib/quartz_torrent/blockstate.rb', line 8 def initialize(pieceIndex, offset, length, peers, blockIndex) @pieceIndex = pieceIndex @offset = offset @length = length @peers = peers @blockIndex = blockIndex end |
Instance Attribute Details
#blockIndex ⇒ Object
Index of the block in units of the blockSize from the BlockState that created this object.
27 28 29 |
# File 'lib/quartz_torrent/blockstate.rb', line 27 def blockIndex @blockIndex end |
#length ⇒ Object
Length of the block in bytes.
21 22 23 |
# File 'lib/quartz_torrent/blockstate.rb', line 21 def length @length end |
#offset ⇒ Object
Offset (in bytes) within the piece where the block begins.
19 20 21 |
# File 'lib/quartz_torrent/blockstate.rb', line 19 def offset @offset end |
#peers ⇒ Object
A list of peers that have the piece this block belongs to. This block can be requested from these peers.
24 25 26 |
# File 'lib/quartz_torrent/blockstate.rb', line 24 def peers @peers end |
#pieceIndex ⇒ Object
The index of the piece that this block belongs to.
17 18 19 |
# File 'lib/quartz_torrent/blockstate.rb', line 17 def pieceIndex @pieceIndex end |