Module: RubyTorrent::ArrayToBitstring
- Defined in:
- lib/rubytorrent/peer.rb
Instance Method Summary collapse
Instance Method Details
#to_bitstring ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubytorrent/peer.rb', line 21 def to_bitstring ret = "\0" bit = 7 map do |b| if bit == -1 ret += "\0" bit = 7 end ret[ret.length - 1] |= (1 << bit) if b bit -= 1 end ret end |