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