Sha256: 253a7eac7cf70d01132f26852167a615fc65e22979cb06fa3b024b5d5a9f8fa0
Contents?: true
Size: 621 Bytes
Versions: 5
Compression:
Stored size: 621 Bytes
Contents
# encoding: UTF-8 module BEncodr module List def bencode List.bencode(self) end def self.bencode(arrayable) ary = coerce(arrayable) ary.collect do |element| Object.bencode(element) end.unshift(:l).push(:e).join end private def self.coerce(arrayable) if arrayable.respond_to?(:to_a) arrayable.to_a elsif arrayable.respond_to?(:to_ary) arrayable.to_ary else raise BEncodeError, "BEncodr::List.bencode can only be called on an object that provides a to_a or to_ary method." end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
bencodr-3.0.2 | lib/bencodr/list.rb |
bencodr-3.0.1 | lib/bencodr/list.rb |
bencodr-2.0.1 | lib/bencodr/list.rb |
bencodr-3.0.0 | lib/bencodr/list.rb |
bencodr-2.0.0 | lib/bencodr/list.rb |