Class: QuartzTorrent::Metainfo::Info
- Inherits:
-
Object
- Object
- QuartzTorrent::Metainfo::Info
- Defined in:
- lib/quartz_flow/mock_client.rb,
lib/quartz_flow/wrappers.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
Array of FileInfo objects.
-
#name ⇒ Object
Suggested file or directory name.
-
#pieceLen ⇒ Object
Length of each piece in bytes.
-
#pieces ⇒ Object
Array of SHA1 digests of all peices.
-
#private ⇒ Object
True if no external peer source is allowed.
Instance Method Summary collapse
-
#dataLength ⇒ Object
Total length of the torrent data in bytes.
-
#initialize ⇒ Info
constructor
A new instance of Info.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Info
Returns a new instance of Info.
44 45 46 47 48 49 50 |
# File 'lib/quartz_flow/mock_client.rb', line 44 def initialize @files = [] @name = nil @pieceLen = 0 @pieces = [] @private = false end |
Instance Attribute Details
#files ⇒ Object
Array of FileInfo objects
53 54 55 |
# File 'lib/quartz_flow/mock_client.rb', line 53 def files @files end |
#name ⇒ Object
Suggested file or directory name
55 56 57 |
# File 'lib/quartz_flow/mock_client.rb', line 55 def name @name end |
#pieceLen ⇒ Object
Length of each piece in bytes. The last piece may be shorter than this.
57 58 59 |
# File 'lib/quartz_flow/mock_client.rb', line 57 def pieceLen @pieceLen end |
#pieces ⇒ Object
Array of SHA1 digests of all peices. These digests are in binary format.
59 60 61 |
# File 'lib/quartz_flow/mock_client.rb', line 59 def pieces @pieces end |
#private ⇒ Object
True if no external peer source is allowed.
61 62 63 |
# File 'lib/quartz_flow/mock_client.rb', line 61 def private @private end |
Instance Method Details
#dataLength ⇒ Object
Total length of the torrent data in bytes.
64 65 66 |
# File 'lib/quartz_flow/mock_client.rb', line 64 def dataLength files.reduce(0){ |memo,f| memo + f.length} end |
#to_h ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/quartz_flow/wrappers.rb', line 12 def to_h result = {} result[:name] = @name result[:pieceLen] = @pieceLen result[:files] = @files.collect{ |e| e.to_h } result end |