Class: Torrent::Info
- Inherits:
-
Object
- Object
- Torrent::Info
- Defined in:
- lib/immutablebox.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#info_hash ⇒ Object
readonly
Returns the value of attribute info_hash.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#piece_length ⇒ Object
readonly
Returns the value of attribute piece_length.
-
#pieces ⇒ Object
readonly
Returns the value of attribute pieces.
Instance Method Summary collapse
- #infohash ⇒ Object
-
#initialize(info) ⇒ Info
constructor
A new instance of Info.
- #magnet ⇒ Object
Constructor Details
#initialize(info) ⇒ Info
Returns a new instance of Info.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/immutablebox.rb', line 17 def initialize(info) @info = info @info_hash = Digest::SHA1.digest(BEncode.dump(info)) @piece_length = info['piece length'] @name = info['name'] @files = info['files'] || [{ 'length' => info['length'], 'path' => [@name] }] pieces = info['pieces'] @pieces = (pieces.size / 20).times.map{|i| pieces[i * 20, 20]} end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
31 32 33 |
# File 'lib/immutablebox.rb', line 31 def files @files end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
29 30 31 |
# File 'lib/immutablebox.rb', line 29 def info @info end |
#info_hash ⇒ Object (readonly)
Returns the value of attribute info_hash.
30 31 32 |
# File 'lib/immutablebox.rb', line 30 def info_hash @info_hash end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
33 34 35 |
# File 'lib/immutablebox.rb', line 33 def name @name end |
#piece_length ⇒ Object (readonly)
Returns the value of attribute piece_length.
32 33 34 |
# File 'lib/immutablebox.rb', line 32 def piece_length @piece_length end |
#pieces ⇒ Object (readonly)
Returns the value of attribute pieces.
34 35 36 |
# File 'lib/immutablebox.rb', line 34 def pieces @pieces end |