Class: Reenrb::ChangesFile
- Inherits:
-
Object
- Object
- Reenrb::ChangesFile
- Defined in:
- lib/reenrb/changes_file.rb
Overview
Manages a temporary file with requested changes
Constant Summary collapse
- INSTRUCTIONS =
<<~COMMENTS # Edit the names of any files/folders to rename or move them # - Put a preceeding dash to delete a file or empty folder COMMENTS
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
Instance Method Summary collapse
- #allow_changes(editor, &block) ⇒ Object
-
#initialize(requested_list) ⇒ ChangesFile
constructor
A new instance of ChangesFile.
Constructor Details
#initialize(requested_list) ⇒ ChangesFile
Returns a new instance of ChangesFile.
16 17 18 19 20 21 |
# File 'lib/reenrb/changes_file.rb', line 16 def initialize(requested_list) @list_file = Tempfile.new("reenrb-") @list_file.write(INSTRUCTIONS) @list_file.write(requested_list.join("\n")) @list_file.close end |
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
14 15 16 |
# File 'lib/reenrb/changes_file.rb', line 14 def list @list end |
Instance Method Details
#allow_changes(editor, &block) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/reenrb/changes_file.rb', line 23 def allow_changes(editor, &block) await_editor(editor) if editor @list = File.read(path).split("\n").map(&:strip) .reject { |line| line.start_with?("#") || line.empty? } block&.call(self) @list end |