Sha256: 7e62400d03167c38bd5b0d66cdc67f92066a1d89d3c25bb9af40b97d52292750

Contents?: true

Size: 489 Bytes

Versions: 1

Compression:

Stored size: 489 Bytes

Contents

# encoding: UTF-8

module BEncodr
  module IO
    module ClassMethods
      def bencode(fd, object)
        open(fd, "wb") {|file| file.bencode(object)}
      end
      
      def bdecode(fd)
        open(fd, "rb") {|file| file.bdecode}
      end
    end
    
    def bencode(object)
      write(Object.bencode(object))
    end
    
    def bdecode
      Object.bdecode(read.force_encoding('UTF-8'))
    end
    
    def self.included(base)
      base.extend ClassMethods
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bencodr-3.0.0 lib/bencodr/io.rb