Class: QuartzTorrent::EmptyBitfield

Inherits:
Bitfield
  • Object
show all
Defined in:
lib/quartz_torrent/bitfield.rb

Overview

A bitfield that is always empty.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEmptyBitfield

Returns a new instance of EmptyBitfield.



230
231
232
# File 'lib/quartz_torrent/bitfield.rb', line 230

def initialize
  @length = 0
end

Instance Attribute Details

#lengthObject (readonly)

Length of the Bitfield in bits.



235
236
237
# File 'lib/quartz_torrent/bitfield.rb', line 235

def length
  @length
end

Instance Method Details

#allClear?Boolean

Are all bits in the Bitfield clear?

Returns:

  • (Boolean)


261
262
263
# File 'lib/quartz_torrent/bitfield.rb', line 261

def allClear?
  true
end

#allSet?Boolean

Are all bits in the Bitfield set?

Returns:

  • (Boolean)


256
257
258
# File 'lib/quartz_torrent/bitfield.rb', line 256

def allSet?
  false
end

#byteLengthObject

Length of the Bitfield in bytes.



238
239
240
# File 'lib/quartz_torrent/bitfield.rb', line 238

def byteLength
  0
end

#clear(bit) ⇒ Object

Clear the bit at index ‘bit’ to 0.



247
248
# File 'lib/quartz_torrent/bitfield.rb', line 247

def clear(bit)
end

#clearAllObject

Clear all bits in the field to 0.



270
271
# File 'lib/quartz_torrent/bitfield.rb', line 270

def clearAll
end

#complimentObject

Calculate the compliment of this bitfield, and return the result as a new bitfield.



297
298
299
# File 'lib/quartz_torrent/bitfield.rb', line 297

def compliment
  self
end

#compliment!Object

Update this bitfield to be the compliment of itself.



302
303
304
# File 'lib/quartz_torrent/bitfield.rb', line 302

def compliment!
  self
end

#copyFrom(bitfield) ⇒ Object

Set the contents of this bitfield to be the same as the passed bitfield. An exception is thrown if the passed bitfield is smaller than this.



292
293
# File 'lib/quartz_torrent/bitfield.rb', line 292

def copyFrom(bitfield)
end

#countSetObject

Count the number of bits that are set. Slow: could use lookup table.



321
322
323
# File 'lib/quartz_torrent/bitfield.rb', line 321

def countSet
  0
end

#intersection(bitfield) ⇒ Object

Calculate the intersection of this bitfield and the passed bitfield, and return the result as a new bitfield.



281
282
283
# File 'lib/quartz_torrent/bitfield.rb', line 281

def intersection(bitfield)
  self
end

#intersection!(bitfield) ⇒ Object

Update this bitfield to be the intersection of this bitfield and the passed bitfield.



286
287
288
# File 'lib/quartz_torrent/bitfield.rb', line 286

def intersection!(bitfield)
  self
end

#serializeObject

Serialize this bitfield as a string.



307
308
309
# File 'lib/quartz_torrent/bitfield.rb', line 307

def serialize
  ""
end

#set(bit) ⇒ Object

Set the bit at index ‘bit’ to 1.



243
244
# File 'lib/quartz_torrent/bitfield.rb', line 243

def set(bit)
end

#set?(bit) ⇒ Boolean

Returns true if the bit is set, false otherwise.

Returns:

  • (Boolean)


251
252
253
# File 'lib/quartz_torrent/bitfield.rb', line 251

def set?(bit)
  false
end

#setAllObject

Set all bits in the field to 1.



266
267
# File 'lib/quartz_torrent/bitfield.rb', line 266

def setAll
end

#to_s(groupsOf = 8) ⇒ Object

Return a display string representing the bitfield.



316
317
318
# File 'lib/quartz_torrent/bitfield.rb', line 316

def to_s(groupsOf = 8)
  "empty"
end

#union(bitfield) ⇒ Object

Calculate the union of this bitfield and the passed bitfield, and return the result as a new bitfield.



275
276
277
# File 'lib/quartz_torrent/bitfield.rb', line 275

def union(bitfield)
  self
end

#unserialize(s) ⇒ Object

Unserialize this bitfield from a string.



312
313
# File 'lib/quartz_torrent/bitfield.rb', line 312

def unserialize(s)
end