Sha256: 7372b11b62a29e3e8030776edae65ed39f63bbd4b89a95ac21de4cc16f3db078
Contents?: true
Size: 1.2 KB
Versions: 8
Compression:
Stored size: 1.2 KB
Contents
module Approvals module Writers class BinaryWriter EXCEPTION_WRITER = Proc.new do |data, file| raise "BinaryWriter#callback missing" end def initialize(opts = {}) self.autoregister = opts[:autoregister] || true self.detect = opts[:detect] self.extension = opts[:extension] || '' self.write = opts[:write] || EXCEPTION_WRITER self.format = opts[:format] || :binary end attr_accessor :autoregister attr_accessor :extension attr_accessor :write attr_accessor :detect attr_reader :format def format=(sym) unregister if autoregister @format = sym register if autoregister end def register if @format Writer::REGISTRY[@format] = self Approval::BINARY_FORMATS << @format Approval::IDENTITIES[@format] = @detect if @detect end end def unregister if @format Writer::REGISTRY.delete!(@format) Approval::BINARY_FORMATS.delete!(@format) Approval::IDENTITIES.delete!(@format) end end def write(data,path) @write.call(data,path) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems