Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/rubytorrent/bencoding.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bencoded?(c) ⇒ Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/rubytorrent/bencoding.rb', line 128

def self.bencoded?(c)
  c == ?l
end

.parse_bencoding(c, s) ⇒ Object



132
133
134
135
136
# File 'lib/rubytorrent/bencoding.rb', line 132

def self.parse_bencoding(c, s)
  ret = RubyTorrent::BStream.new(s).map { |x| x }
  raise RubyTorrent::BEncodingError, "missing list terminator" unless s.getc == ?e
  ret
end

Instance Method Details

#to_bencodingObject



124
125
126
# File 'lib/rubytorrent/bencoding.rb', line 124

def to_bencoding
  "l" + self.map { |e| e.to_bencoding }.join + "e"
end