Class: Approvals::Writers::BinaryWriter
- Inherits:
-
Object
- Object
- Approvals::Writers::BinaryWriter
- Defined in:
- lib/approvals/writers/binary_writer.rb
Constant Summary collapse
- EXCEPTION_WRITER =
Proc.new do |data, file| raise "BinaryWriter#callback missing" end
Instance Attribute Summary collapse
-
#autoregister ⇒ Object
Returns the value of attribute autoregister.
-
#detect ⇒ Object
Returns the value of attribute detect.
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#format ⇒ Object
Returns the value of attribute format.
-
#write(data, path) ⇒ Object
Returns the value of attribute write.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BinaryWriter
constructor
A new instance of BinaryWriter.
- #register ⇒ Object
- #unregister ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ BinaryWriter
Returns a new instance of BinaryWriter.
8 9 10 11 12 13 14 |
# File 'lib/approvals/writers/binary_writer.rb', line 8 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 |
Instance Attribute Details
#autoregister ⇒ Object
Returns the value of attribute autoregister.
16 17 18 |
# File 'lib/approvals/writers/binary_writer.rb', line 16 def autoregister @autoregister end |
#detect ⇒ Object
Returns the value of attribute detect.
19 20 21 |
# File 'lib/approvals/writers/binary_writer.rb', line 19 def detect @detect end |
#extension ⇒ Object
Returns the value of attribute extension.
17 18 19 |
# File 'lib/approvals/writers/binary_writer.rb', line 17 def extension @extension end |
#format ⇒ Object
Returns the value of attribute format.
22 23 24 |
# File 'lib/approvals/writers/binary_writer.rb', line 22 def format @format end |
#write(data, path) ⇒ Object
Returns the value of attribute write.
18 19 20 |
# File 'lib/approvals/writers/binary_writer.rb', line 18 def write @write end |
Instance Method Details
#register ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/approvals/writers/binary_writer.rb', line 33 def register if @format Writer::REGISTRY[@format] = self Approval::BINARY_FORMATS << @format Approval::IDENTITIES[@format] = @detect if @detect end end |
#unregister ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/approvals/writers/binary_writer.rb', line 41 def unregister if @format Writer::REGISTRY.delete!(@format) Approval::BINARY_FORMATS.delete!(@format) Approval::IDENTITIES.delete!(@format) end end |