Class: ProcessExecuter::Destinations::FilePath Private
- Inherits:
-
ProcessExecuter::DestinationBase
- Object
- ProcessExecuter::DestinationBase
- ProcessExecuter::Destinations::FilePath
- Defined in:
- lib/process_executer/destinations/file_path.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Handles file path destinations
Instance Attribute Summary collapse
-
#file ⇒ File
readonly
private
The opened file object.
Attributes inherited from ProcessExecuter::DestinationBase
Class Method Summary collapse
-
.handles?(destination) ⇒ Boolean
private
Determines if this class can handle the given destination.
Instance Method Summary collapse
-
#close
private
Closes the file if it's open.
-
#initialize(destination) ⇒ FilePath
constructor
private
Initializes a new file path destination handler.
-
#write(data) ⇒ Integer
private
Writes data to the file.
Methods inherited from ProcessExecuter::DestinationBase
#compatible_with_monitored_pipe?, compatible_with_monitored_pipe?, #string
Constructor Details
permalink #initialize(destination) ⇒ FilePath
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a new file path destination handler
Opens the file at the given path for writing.
16 17 18 19 |
# File 'lib/process_executer/destinations/file_path.rb', line 16 def initialize(destination) super @file = File.open(destination, 'w', 0o644) end |
Instance Attribute Details
permalink #file ⇒ File (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The opened file object
24 25 26 |
# File 'lib/process_executer/destinations/file_path.rb', line 24 def file @file end |
Class Method Details
permalink .handles?(destination) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines if this class can handle the given destination
51 52 53 |
# File 'lib/process_executer/destinations/file_path.rb', line 51 def self.handles?(destination) destination.is_a? String end |
Instance Method Details
permalink #close
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Closes the file if it's open
43 44 45 |
# File 'lib/process_executer/destinations/file_path.rb', line 43 def close file.close unless file.closed? end |
permalink #write(data) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Writes data to the file
35 36 37 38 |
# File 'lib/process_executer/destinations/file_path.rb', line 35 def write(data) super file.write data end |