Sha256: ab0dd51d6dd1378a3344dc5a4c44f3ba6ee3171064b5f5f5868cae35f169ec70

Contents?: true

Size: 379 Bytes

Versions: 3

Compression:

Stored size: 379 Bytes

Contents

module Bencoding
  module Object
    
    def attributes_for_bencoding
      instance_variables
    end
    
    def for_bencoding
      attributes_for_bencoding.inject({}) do |hash, attribute|
        hash[attribute.to_s[1..-1]] = instance_variable_get(attribute)
        hash
      end
    end
    
    def to_bencoding
      for_bencoding.to_bencoding
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simonmenke-bencoding-0.0.2 lib/bencoding/object.rb
simonmenke-bencoding-0.0.3 lib/bencoding/object.rb
simonmenke-bencoding-0.0.4 lib/bencoding/object.rb