-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve torrent codes handling and download pieces
- Loading branch information
Showing
7 changed files
with
128 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require "observer" | ||
|
||
module Rutorrent | ||
class Piece | ||
include Observable | ||
attr_reader :blocks, :piece_index, :buffer | ||
|
||
def initialize(blocks, piece_index) | ||
@blocks = blocks | ||
@piece_index = piece_index | ||
@piece_observer = PieceObserver.new(self) | ||
end | ||
|
||
def blocks=(new_element) | ||
blocks << new_element | ||
changed | ||
notify_observers | ||
end | ||
|
||
def update_buffer | ||
# buffer.write(blocks.last) | ||
end | ||
|
||
def buffer_content | ||
buffer.string | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Rutorrent | ||
class PieceObserver | ||
attr_reader :piece | ||
|
||
def initialize(piece) | ||
@piece = piece | ||
piece.add_observer(self) | ||
end | ||
|
||
def update | ||
# piece.update_buffer | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters