Class: QuartzTorrent::Metainfo::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/quartz_flow/mock_client.rb,
lib/quartz_flow/wrappers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInfo

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

#filesObject

Array of FileInfo objects



53
54
55
# File 'lib/quartz_flow/mock_client.rb', line 53

def files
  @files
end

#nameObject

Suggested file or directory name



55
56
57
# File 'lib/quartz_flow/mock_client.rb', line 55

def name
  @name
end

#pieceLenObject

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

#piecesObject

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

#privateObject

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

#dataLengthObject

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_hObject



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