module Editor
def self.open_editor(initial_text)
-
(String)
- The updated text.
Parameters:
-
initial_text
(String
) -- The initial text to display in the editor.
def self.open_editor(initial_text) file_handle = Tempfile.create file_handle.write(initial_text) file_handle.close # Open the editor with the temporary file. system('vim', file_handle.path) updated_text = nil # Read the updated text from the file. File.open(file_handle.path, 'r') do |f| updated_text = f.read WorkLogger.debug("Updated text: #{updated_text}") end File.unlink(file_handle.path) updated_text end