Module: Bencoding::Object

Defined in:
lib/bencoding/object.rb

Instance Method Summary collapse

Instance Method Details

#attributes_for_bencodingObject



5
6
7
# File 'lib/bencoding/object.rb', line 5

def attributes_for_bencoding
  instance_variables
end

#for_bencodingObject



9
10
11
12
13
14
# File 'lib/bencoding/object.rb', line 9

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

#to_bencodingObject



16
17
18
# File 'lib/bencoding/object.rb', line 16

def to_bencoding
  for_bencoding.to_bencoding
end