Class: Burner::Library::IO::Write
- Inherits:
-
OpenFileBase
- Object
- Job
- JobWithRegister
- OpenFileBase
- Burner::Library::IO::Write
- Defined in:
- lib/burner/library/io/write.rb
Overview
Constant Summary
Constants inherited from JobWithRegister
Instance Attribute Summary collapse
-
#supress_side_effect ⇒ Object
readonly
Returns the value of attribute supress_side_effect.
Attributes inherited from OpenFileBase
Attributes inherited from JobWithRegister
Attributes inherited from Job
Instance Method Summary collapse
-
#initialize(path:, binary: false, disk: {}, name: '', register: DEFAULT_REGISTER, supress_side_effect: false) ⇒ Write
constructor
A new instance of Write.
- #perform(output, payload) ⇒ Object
Methods included from Util::Arrayable
Constructor Details
#initialize(path:, binary: false, disk: {}, name: '', register: DEFAULT_REGISTER, supress_side_effect: false) ⇒ Write
Returns a new instance of Write.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/burner/library/io/write.rb', line 24 def initialize( path:, binary: false, disk: {}, name: '', register: DEFAULT_REGISTER, supress_side_effect: false ) @supress_side_effect = supress_side_effect || false super( binary: binary, disk: disk, name: name, path: path, register: register ) end |
Instance Attribute Details
#supress_side_effect ⇒ Object (readonly)
Returns the value of attribute supress_side_effect.
22 23 24 |
# File 'lib/burner/library/io/write.rb', line 22 def supress_side_effect @supress_side_effect end |
Instance Method Details
#perform(output, payload) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/burner/library/io/write.rb', line 43 def perform(output, payload) logical_filename = job_string_template(path, output, payload) physical_filename = nil output.detail("Writing: #{logical_filename}") time_in_seconds = Benchmark.measure do physical_filename = disk.write(logical_filename, payload[register], binary: binary) end.real output.detail("Wrote to: #{physical_filename}") return if supress_side_effect output.detail("Saving to side effects: #{logical_filename}") side_effect = SideEffects::WrittenFile.new( logical_filename: logical_filename, physical_filename: physical_filename, time_in_seconds: time_in_seconds ) payload.add_side_effect(side_effect) end |