Module: BEncode::String
- Defined in:
- lib/bencode/string.rb
Defined Under Namespace
Class Method Summary collapse
-
.register(type) ⇒ Object
Registers a class as an object that can be converted into a bencoded string.
Class Method Details
.register(type) ⇒ Object
Registers a class as an object that can be converted into a bencoded string. Class must have instance method to_s or to_str.
class MyClass
def to_s
"string"
end
end
BEncode::String.register MyClass
my_class = MyClass.new
my_class.bencode #=> "6:string"
35 36 37 |
# File 'lib/bencode/string.rb', line 35 def self.register(type) type.send :include, Generic::InstanceMethods end |