Sha256: 6e5c7059ae2a3d23e030738d90e954ed328c133f50575d5128b95b6024d41cb6

Contents?: true

Size: 514 Bytes

Versions: 1

Compression:

Stored size: 514 Bytes

Contents

class Array
  #
  # Bencodes the Array object. Bencoded arrays are represented as
  # +lxe+, where +x+ is zero or more bencoded objects.
  #
  #   [1, "foo"].bencode   #=> "li1e3:fooe"
  #
  def bencode
    begin
      "l#{map{|obj| obj.bencode }.join('')}e"
    rescue BEncode::EncodeError
      raise BEncode::EncodeError, "array items must be bencodable"
    # TODO: This is probably a bad idea...
    rescue SystemStackError
      raise BEncode::EncodeError, "cannot encode recursive array"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bencode-0.5.0 lib/bencode/encode/array.rb